Easy IoT General

IO Expansion Shield for Intel Edison - Input Pin Problem

userHead mjain 2015-04-22 19:13:23 4560 Views0 Replies
I purchased a IO Expansion Shield for Intel Edison (Part # DRF0338). I am trying to use it and as far as setting the pin for output in Arduino IDE works fine and I am able to use a motor when I use a npn transistor. However I am having a problem with input pin. The pin does not seem to respond properly to the input voltage. Can you please guide me how to use it properly. Currently I am using a push button (on pin 2) to turn an LED on the other pin (4). I am using a voltage divider using 1K-Ohm resistors to get 2- 2.5 V volts at the pin (from 5V Vcc)to make the pin high (as I think the logic high is 1.8V). However it does not seems to respond. You help is greatly appreciated in this matter. Also is there any way to get 1.8V out of this board and change Vcc to 3.3 V.

Following is the program:

int led = 4;
int buttonPin = 2;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
pinMode(buttonPin, INPUT);
pinMode(buttonPin, LOW);


Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {

// read the input pin:
int buttonState = digitalRead(buttonPin);
// print out the state of the button:
Serial.println(buttonState);
delay(5); // delay in between reads for stability

if(digitalRead(buttonPin) == LOW)
{
digitalWrite(led, LOW); // turn the LED on (HIGH is the voltag level)
}
if(digitalRead(buttonPin) == HIGH)
{
digitalWrite(led, HIGH); // turn the LED off by making the voltage LOW
}
// wait for a second
}


Thank you,

Mohit