Hello,
I wanted to start project 15 in arduino starter kit. THe problem is I don't have anything to hack.
So, I though about hacking a push button.
const int optoPin = 2;
const int pushButtonPin = 7;
int pushButtonValue;
void setup() {
// put your setup code here, to run once:
pinMode(optoPin, OUTPUT);
pinMode(pushButtonPin, INPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(optoPin, HIGH);
pushButtonValue=digitalRead(pushButtonPin);
Serial.println(pushButtonValue);
delay(10);
digitalWrite(optoPin, LOW);
pushButtonValue=digitalRead(pushButtonPin);
Serial.println(pushButtonValue);
delay(1000);
}
I tried to test the output of this code. I get 0 0 0 0 0 0 0 0 .
I was expecting 1 0 1 0 1 0 .
I guess the hacking of the push button attempt was failed.
Any idea why is that ? or my code is wrong or the setup i have is wrong ?
Any idea what is going on ?