three push buttons controlling three leds

Well i am trying to create a simple project that with 3 buttons i will controll 3 leds. If button 1 is pressed led one is on , if 2 led 2 and if 3 led 3. If idle after 15 minutes all are off until a button is pressed.

i came up with that reading some tutorials but by default leds are on.
Any suggestions?

i havent addresed the issue with the idle 15 minutes time yet.

const int LM = 12; // the pin for the man led
const int LW = 11; // the pin for the woman led
const int LN = 10; // the pin for the none led

const int bM = 7; // the pin for the man button 
const int bW = 8; // the pin for the woman button
const int bN = 9; // the pin for the none button

int valM = 0; //is used to store the values of the man pin
int valW = 0; //is used to store the values of the man pin
int valN = 0; //is used to store the values of the man pin


void setup() {
 // put your setup code here, to run once:
 {
 Serial.begin(9600);  
 Serial.println("--- Start Serial Monitor SEND_RCVE ---");
   Serial.println(" Type in Box above, . ");
 Serial.println("(Decimal)(Hex)(Character)");  
 Serial.println(); 
}
//--(end setup )---
pinMode(LM, OUTPUT);
pinMode(LW, OUTPUT);
pinMode(LN, OUTPUT);
pinMode(bM, INPUT);
pinMode(bW, INPUT);
pinMode(bN, INPUT);
}

void loop() {
 // put your main code here, to run repeatedly:
valM = digitalRead(bM);
valW = digitalRead(bW);
valN = digitalRead(bN);

if (valN == HIGH) {
 digitalWrite(LN, HIGH);
 Serial.print(" LED NONE is ON ");
 digitalWrite(LM, LOW);
 digitalWrite(LW, LOW);
 }
 else if (valM == HIGH) {
 digitalWrite(LN, LOW);
 digitalWrite(LM, HIGH);
 Serial.print(" LED MAN is ON ");
 digitalWrite(LW, LOW);
 }
 else if (valW == HIGH) {
     digitalWrite(LN, LOW);
     digitalWrite(LM, LOW);
     digitalWrite(LW, HIGH);
     Serial.print(" LED WOMAN is ON ");
 }
}

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Please show how you have got your buttons wired.

Thanks.. Tom.. :slight_smile:

What does it do? What should it do that's different?

Steve

Change these lines from
pinMode(bM, INPUT);
to
pinMode(bM, INPUT_PULLUP);

and
if (valN == HIGH) {
to
if (valN == LOW) {

and wire the buttons to connect to the pin and Gnd only.

"If nonw after 15 minutes" I don't see a nonw.

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html . Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Please show how you have got your buttons wired.

Thanks.. Tom.. :slight_smile:

Thank you i wil do so later today

CrossRoads:
Change these lines from
pinMode(bM, INPUT);
to
pinMode(bM, INPUT_PULLUP);

and
if (valN == HIGH) {
to
if (valN == LOW) {

and wire the buttons to connect to the pin and Gnd only.

"If nonw after 15 minutes" I don't see a nonw.

Thank you.
The pinMode change to INPUT_PULLUP should be applied to all ? bM bW and bN?
The ""If nonw after 15 minutes" I don't see a nonw."" is a typo :slight_smile: i mean if idle for 15 minutes. But as i said i havent addressed this problem in the code yet.