Hi,as this is my first ever post on any forum,so please excuse me for any mistakes. I have a couple of questions regarding some issues i am facing when using the Edison. First one is as follow
As i have used ardunio before, so i am using the Ardunio IDE for coding the edison.The code i am trying to run is a fairly simple one.
int ledPin = 13; // choose the pin for the LED
int ledPin2 = 12;
int inPin = 7; // choose the input pin (for a pushbutton)
int inPin2 = 8;
int val = 0; // variable for reading the pin status
int val1 = 0;
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input
pinMode(ledPin2, OUTPUT); // declare LED as output
pinMode(inPin2, INPUT); // declare pushbutton as input
val = digitalRead(inPin); // read input value
if (val == HIGH) // check if the input is HIGH (button released)
digitalWrite(ledPin, LOW); // turn LED OFF
digitalWrite(ledPin, HIGH); // turn LED ON
val1 = digitalRead(inPin2); // read input value
if (val1 == HIGH) // check if the input is HIGH (button released)
digitalWrite(ledPin2, LOW); // turn LED OFF
digitalWrite(ledPin2, HIGH); // turn LED ON
What i dont understand is, when i change the condition of the if, i want the led to glow when i press a push button, the led doesn't go off when pushbutton state is low. The led stays on regardless of the state of the push button.
The second issue is, I might be wrong, but I think the edison is not properly grounded when fixed on to the ardunio extension board. When ever i put my finger on the edison board, on the metal plate with edison written on it, the code seems to work and as soon as i remove my finger off the plate it goes back to same old state.
The third issue has to do with using the I2C option. I have a motor driver that uses I2C communication to work. So could anyone point me to the right direction with using I2C, how to use it and any possible code to try. I have gone through many websites and tried different code but all of them didn't work.
The final thing i want to ask is, when I program the edison, do i have to keep the usb plugged in for the program to work ? this is some strange thing that is happening as it doesn't happen with an ardunio. When ever I unplug the usb, it seems that there is no program in the edison and nothing happens, but when i keep the usb plugged what ever i program, it runs perfectly
I was trying to replicate your issue with the code however I had issues with my Edison and I am currently flashing it with Flash Tool Lite. Nevertheless, I can give you a few suggestions:
Instead of setting the if statement to do an else, why don't you try setting it as "different than". I mean, if you are not grounding the input when a signal is not present, the input may have noise. I would modify your code to look like this:
val = digitalRead(inPin);
val1 = digitalRead(inPin2);
if (val == HIGH)
if(val != HIGH)
if (val1 == HIGH)
The grounding issue is very weird, the board's contacts may be dirty, have you already tried cleaning them with a dielectric cleaner?
Regarding I2C examples, the examples included in the Arduino IDE under the Wire category should work with your Edison.
And regarding your last question, which image are you using?