Go Down

Topic: second input isn't read by the arduino (Read 4055 times) previous topic - next topic


Jan 19, 2011, 05:35 pm Last Edit: Jan 19, 2011, 07:12 pm by nadakabil Reason: 1
Hello there,
the problem i'm facing is that i can't get the arduino to read the 2nd input (pushbutton) even though i'm sure it's connected properly because i tried to use it as the 1st one instead and it worked..

so i have 2 pushbuttons and 4 LED's and i want the 1st pushbutton to make LED1 light and LED2 blink and then when i press the 2nd pushbutton i want LED 2 stop blinking and just be lit and LED3 to start blinking..  but i can't get the 2nd pushbutton 2 work... it doesn't read it at all.. so can someone please see my code and tell me what's wrong.. or why it doesnt read it?

Code: [Select]
#define LED 13 // THE PIN FOR THE LED
#define SENS1 0


int pin1 = 1;
int pin2 = 2;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
int pin11 =11;

int sensorValue = 0;
int oldSensorValue=0;

boolean blinking = false;

void setup () {
pinMode (8, OUTPUT);
pinMode (9, OUTPUT);
pinMode (10, OUTPUT);
pinMode (11, OUTPUT);
pinMode (1, INPUT);
pinMode (2, INPUT);

void loop (){
oldSensorValue = sensorValue;
sensorValue = digitalRead(pin1);

if(sensorValue == HIGH && oldSensorValue == LOW){
     digitalWrite(pin8, HIGH);
if(sensorValue == HIGH && blinking == true){
     blinking = false;
   else if(sensorValue == HIGH && blinking == false){
     blinking = true;
if (blinking == true) {
   digitalWrite(pin9, HIGH);
   digitalWrite(pin9, LOW);
 sensorValue = digitalRead(pin2);
if (blinking == false && sensorValue == HIGH){
  digitalWrite(pin9, HIGH);
  while (pin9, HIGH) {
  digitalWrite(pin10, HIGH);
  digitalWrite(pin10, LOW);
  delay(200); }
else if (blinking == false && sensorValue == HIGH){
  digitalWrite(pin9, HIGH);
  digitalWrite(pin10, HIGH);
  while (pin10, HIGH) {
  digitalWrite(pin11, HIGH);
  digitalWrite(pin11, LOW);
  delay(200); }

thank you =)

Coding Badly

This is not an appropriate section of the forum for your post.

I suggest creating a new identical post in Softtware / Troubleshooting or Hardware / Troubleshooting then please delete your post here.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131