1 2 Previous Next 28 Replies Latest reply on Apr 14, 2016 12:31 PM by Dmcp7600

    Can someone help with my Galileo Gen 2 analog pin set up. Im lost...

    Dmcp7600

      On the Galileo Gen 2 arduino board. How do i utilize the analog pins? I have used up pins 2 through 9. Using a 4x4 keypad, a user will enter a code and the servo motor will turn 180 degrees. unlocking a door.

      Please show me what librarys i need to install because i found softPMW and softPMWtimer online and it didnt help. It gives me a "not in directory error"

        • 1. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
          FGT

          What IDE are you using/how are you developing your code?

           

          Fernando.

          • 2. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
            Dmcp7600

            I am using Arduino IDE. Code is written in C++.

            • 3. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
              FGT

              Plase send the sketch you are using and please copy the error (or just send the screenshot)

               

              Why do you want to use PWM? Pls send the servo motor details you are trying to use.

               

              Fernando.

              • 4. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                Dmcp7600

                OK i will post sketch after this. My instructor said that is the only way to enable the usage of pin A0-A5. I have used up all the pins up on the base shield that comes with the grove starter it plus, attaching a 4x4 Keypad to pins 2 through 9. only pins left are is pin 10 through 13 but they arent accessible with the shield. i will post the images and sketch right after this.

                • 5. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                  Dmcp7600

                  #include <SoftPWM.h> //i installed these libraries correctly but have a directory error.

                  #include <SoftPWM_timer.h>

                   

                   

                   

                   

                  #include "Printable.h"

                  #include "Servo.h"

                  #include "Wire.h"

                  #include "lcd_I2C.h"

                  #include "Arduino.h"

                  #include "rgb_lcd.h"

                   

                   

                   

                  /* ==================================================================================

                  File:      keypad_password_servo.ino

                  Author:    Darwynn McPherson

                   

                  // ==================================================================================*/

                   

                  #include <Password.h> //http://playground.arduino.cc/uploads/Code/Password.zip use password library

                  #include <Keypad.h> //http://www.arduino.cc/playground/uploads/Code/Keypad.zip  //tells to use keypad library

                  #include <Servo.h> //tells to use servo library

                  #include <Wire.h>

                  #include <lcd_I2C.h>

                  #include <Streaming.h>

                  #include <Printable.h>

                   

                   

                  Servo myservo; // create servo object to control a servo

                                  // a maximum of eight servo objects can be created

                  int pos = 0;    // variable to store the servo position

                   

                  Password password = Password( "1111" ); //password to unlock box, can be changed

                   

                  rgb_lcd lcd;

                  const int colorR = 255;

                  const int colorG = 0;

                  const int colorB = 0;

                   

                   

                  const byte ROWS = 4; // Four rows

                  const byte COLS = 4; // columns

                  // Define the Keymap

                  char keys[ROWS][COLS] = {

                  {'1','2','3','A'},

                  {'4','5','6','B'},

                  {'7','8','9','C'},

                  {'*','0','#','D'}

                  };

                  // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.

                  byte rowPins[ROWS] = { 2, 3, 4, 5 };// Connect keypad COL0, COL1 and COL2 to these Arduino pins.

                  byte colPins[COLS] = { 6, 7, 8, 9 };

                   

                   

                  // Create the Keypad

                  Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

                   

                  void setup(){

                    Serial.begin(9600);

                    Serial.write(254);

                    Serial.write(0x01);

                    delay(200);

                    pinMode(11, OUTPUT);  //green light

                    pinMode(12, OUTPUT);  //red light

                    pinMode(A0, OUTPUT);//My attempt to try to assign pin numbers

                  digitalWrite(A0, HIGH);

                    myservo.attach(A0); //servo on digital pin A0 //servo

                    keypad.addEventListener(keypadEvent); //add an event listener for this keypad

                    // set up the LCD's number of columns and rows:

                      lcd.begin(16, 2);

                      lcd.setRGB(colorR, colorG, colorB);

                    }

                   

                  void loop(){

                    keypad.getKey();

                    myservo.write(pos++);

                    delay(5);

                    }

                    //take care of some special events

                    void keypadEvent(KeypadEvent eKey){

                    switch (keypad.getState()){

                    case PRESSED:

                   

                    Serial.print("Enter:Access Code ");

                    Serial.println(eKey);

                    delay(10);

                   

                    Serial.write(254);

                   

                    switch (eKey){

                      case '#': checkPassword(); delay(1); break;

                     

                      case '*': password.reset(); delay(1); break;

                     Serial.println("Now Re-enter");

                     

                       default: password.append(eKey); delay(1);

                  }

                  }

                  }

                  void checkPassword(){

                   

                  if (password.evaluate()){  //if password is right open box

                     

                      Serial.println("Access Granted");

                      lcd.print("Access Granted!");

                      myservo.write(pos++); //160deg

                      delay(2500);

                      lcd.clear();

                      Serial.println("Door is open");

                          Serial.write(254);delay(10);

                      //Add code to run if it works 

                      

                          digitalWrite(11, HIGH);//turn on

                      delay(500); //wait 5 seconds

                      digitalWrite(11, LOW);// turn off

                     

                     

                  }else{

                      Serial.println("Access Denied"); //if passwords wrong keep box locked

                      lcd.print("Access Denied");

                      myservo.write(pos--); // tell servo to go to variable position

                      delay(2500);

                      lcd.clear();

                      Serial.println("Press * to reset");

                      Serial.write(254);delay(10);

                      //add code to run if it did not work

                         

                      digitalWrite(12, HIGH); //turn on

                      delay(500); //wait 5 seconds

                      digitalWrite(12, LOW);//turn off

                     

                  }

                  }

                  • 6. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                    Dmcp7600

                    THIS IS THE ERROR CODE

                    Arduino: 1.6.0 (Windows 8), Board: "Intel® Galileo Gen2"

                     

                    Build options changed, rebuilding all

                     

                    In file included from SenProjKEypad.ino:2:0:

                     

                    C:\Users\BRUIZZR\Documents\Arduino\libraries\SoftPWM/SoftPWM_timer.h:22:20: fatal error: avr/io.h: No such file or directory

                     

                    compilation terminated.

                     

                    Error compiling.

                     

                      This report would have more information with

                      "Show verbose output during compilation"

                      enabled in File > Preferences.

                     

                    THIS IS THE ERROR CODE

                    • 7. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                      Dmcp7600

                      This is the base shield with the pins. base shield.jpe

                      • 8. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                        FGT

                         

                        C:\Users\BRUIZZR\Documents\Arduino\libraries\SoftPWM/SoftPWM_timer.h:22:20: fatal error: avr/io.h: No such file or directory

                         

                        From this error it seems to be that SoftPWM_timer.h depends on avr/io.h which in turn is AVR-dependent, so  think it will not possible to use in Intel Galileo...

                         

                        I do not understand

                        "

                        My instructor said that is the only way to enable the usage of pin A0-A5

                        "

                        did your instructor explain why?

                         

                        A0-A5 are "special" in the sense they have ADC, but they can be used as regular "digital" pins... at least in Arduino and I think it would be possible in Galileo too...

                         

                        Fernando.

                        • 9. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                          Dmcp7600

                          Well he says that i cannot just plug the attachment into the pin and expect it to work without the proper library that enables those pins to be accessible. He sent me this link as a reference in order to download the library.

                           

                          http://www.instructables.com/id/How-to-add-6-extra-pins-to-your-Arduino-with-no-ex/

                          • 10. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                            FGT

                            Dmcp7600 wrote:

                             

                            Well he says that i cannot just plug the attachment into the pin and expect it to work without the proper library that enables those pins to be accessible. He sent me this link as a reference in order to download the library.

                             

                            http://www.instructables.com/id/How-to-add-6-extra-pins-to-your-Arduino-with-no-ex/

                            That URL has rather confusing content/s:

                            a) Pins A0-A5 can be used as digital pins without anything else, no libraries needed, no hardware needed.

                            b) Pins A0-A5 are not "automatically" available for PWM, as indicated in that URL. However, I do not understand the relationship between PWM and a blinking LED... digital pins and signals are (mostly) used for a blinking LED... or maybe I'm missing something.

                             

                            Related to some previous questions:

                            a) Why do you need to use PWM? What is the hardware you have to control via PWM?

                            b) Please send the details of the servo motor you are trying to control.

                             

                            Fernando.

                            • 11. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                              FGT

                              Replying to myself just to confirm that analog pins can be used as regular dgital pins.

                               

                              Sketch:

                              // the setup function runs once when you press reset or power the board
                              void setup() {
                                // initialize digital pin 13 as an output.
                                pinMode(14, OUTPUT);
                              }
                              
                              // the loop function runs over and over again forever
                              void loop() {
                                digitalWrite(14, HIGH);   // turn the LED on (HIGH is the voltage level)
                                delay(1000);              // wait for a second
                                digitalWrite(14, LOW);    // turn the LED off by making the voltage LOW
                                delay(1000);              // wait for a second
                              }
                              
                              

                               

                              Result (A0 = digital pin 14):

                              • 12. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                                Dmcp7600

                                I do not neccessarily have to use PWM? The servo im using is just like any other servo doesnt really require any special attention. I see how that URL can be confusing. However my instructor just responded to me this evening with another link they may work.

                                 

                                Here is the link.

                                 

                                http://waihung.net/arduino-tip-turn-your-analog-pins-into-digital-io/

                                • 13. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                                  FGT

                                  hmmmm... moving target... kind of...

                                   

                                  If

                                  I do not neccessarily have to use PWM? The servo im using is just like any other servo doesnt really require any special attention.

                                  then you should try a servo library (it's documented as a supported library at Arduino - IntelGalileoGen2)... now I'm lost...

                                   

                                  Fernando.

                                  • 14. Re: Can someone help with my Galileo Gen 2 analog pin set up. Im lost...
                                    Dmcp7600

                                    I have found plenty of servo library's and all there examples show connections to pin 0 through 9 none on the Analogs. The LED demonstration was cool but how would you edit that code to set a "Servo" on the analog port A0, A1, etc.?

                                     

                                    Here is a servo example if you could point out in this sketch what needs to be adjusted in the void() function so that i can use analog pins please show me. I will make the adjustment in the sketch and then test whether or not they work. THank you..

                                     

                                    // Sweep

                                    // Darwynn McPherson dmcp7600@students.vsu.edu

                                    // This example code is in the public domain.

                                     

                                     

                                    #include <Servo.h>

                                    const int buttonPin = 2;

                                    const int buttonPin2 = 4;

                                    int buttonState = 0;

                                    int buttonState2 = 0;

                                     

                                    Servo myservo;  // create servo object to control a servo

                                                    // a maximum of eight servo objects can be created

                                     

                                    int pos = 0;    // variable to store the servo position

                                     

                                    void setup()

                                    {

                                    myservo.attach(5); // attaches the servo on pin 5 to the servo object

                                    pinMode(buttonPin, INPUT);

                                    pinMode(buttonPin2, INPUT);

                                    }

                                     

                                     

                                    void loop()

                                    {

                                    buttonState = digitalRead(buttonPin);

                                    buttonState2 = digitalRead(buttonPin2);

                                      if(buttonState == HIGH && pos < 180){

                                     

                                        myservo.write(pos++);              // tell servo to go to position in variable 'pos'

                                        delay(5);                       // waits 15ms for the servo to reach the position

                                      }

                                      if(buttonState2 == HIGH && pos > 3){     // goes from 180 degrees to 0 degrees

                                                                     

                                        myservo.write(pos--);              // tell servo to go to position in variable 'pos'

                                        delay(5);                       // waits 15ms for the servo to reach the position

                                      }

                                    }

                                    1 2 Previous Next