Pages: [1]   Go Down
Author Topic: second input isn't read by the arduino  (Read 3026 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#define LED 13 // THE PIN FOR THE LED
#define SENS1 0


//VARIABLES

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);
    delay(200);
    digitalWrite(pin9, LOW);
    delay(200);}
    
  sensorValue = digitalRead(pin2);
  
    
 if (blinking == false && sensorValue == HIGH){
   digitalWrite(pin9, HIGH);
   while (pin9, HIGH) {
   digitalWrite(pin10, HIGH);
   delay(200);
   digitalWrite(pin10, LOW);
   delay(200); }
 }
else if (blinking == false && sensorValue == HIGH){
   digitalWrite(pin9, HIGH);
   digitalWrite(pin10, HIGH);
   while (pin10, HIGH) {
   digitalWrite(pin11, HIGH);
   delay(200);
   digitalWrite(pin11, LOW);
   delay(200); }
 }
}

thank you =)
« Last Edit: January 19, 2011, 01:12:45 pm by nadakabil » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 200
Posts: 12772
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Pages: [1]   Go Up
Jump to: