So I am finishing up the final touches of a Christmas present, and of course it has difficulties being complete. Im gonna paste the code and then explain the project
int buzzPin = 3;
int inPin1 = 9; // pushbutton connected to digital pin 7
int inPin2 = 10;
int inPin3 = 6;
int val1 = 0;// variable to store the read value
int val2 = 0;
int val3 = 0;
int phase1=0;
int phase2=1;
int phase3=1;
int count=0;
int ender=0;
void setup()
{
Serial.begin(9600);
pinMode(inPin1, INPUT); // sets the digital pin 7 as input
pinMode(inPin2, INPUT);
pinMode(inPin3, INPUT);
pinMode(buzzPin, OUTPUT);
}
void loop()
{
val1 = digitalRead(inPin1); // read the input pin
val2 = digitalRead(inPin2);
val3 = digitalRead(inPin3);
// Serial.print(inPin1);
// Serial.print(inPin2);
//Serial.print(inPin3);
if((val1==HIGH) && (phase1==0))
{
digitalWrite(buzzPin,HIGH);
phase1=1;
phase2=0;
count++;
}
if(val2==HIGH && phase2==0)
{
digitalWrite(buzzPin,HIGH);
phase2=1;
phase3=0;
count=count+1;
// Serial.print(count);
}
Serial.print(count);
if(val3==HIGH && phase3==0)
{
digitalWrite(buzzPin,HIGH);
phase3=1;
count=count+1;
//Serial.print(count);
ender==1;
}
if(count>=3 && ender==1)
{
Serial.print(count);
for(int i=0;i<=2;i++)
{
digitalWrite(buzzPin,HIGH);
delay(500);
digitalWrite(buzzPin,LOW);
delay(500);
}
ender=2;
}
delay(500);
digitalWrite(buzzPin,LOW);
}
So this is the code for a little game to get to the Christmas present. When the blocks are put in the correct order(b,c,a c,a,b a,b,c) the buzzer will sound 3 times and then I will present them with the code to get into a keypad. Now I am very sure I have all the wiring down correctly. But what is happening in when I plug the arduino in I instantly get a buzz. and non of the combinations work. Is it because of how I am checking for the completion of the circuit?
Thanks!
(and sorry for bare details, I will be watching for any answer immediately )