hi there. looking for another bit of help. I have a basic code wright just working a light. at the moment the light is turned on when you press the button, but I want to change it so that the light is always on and gets turned off when the button is pressed. how can I do this. I have tried a few things but no luck getting it to work. thanks in advance
this is the code I have been using
void setup() {
// put your setup code here, to run once:
pinMode(6,0);
pinMode(7,0);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(6) == 0)
digitalWrite(7,1);
else
digitalWrite(7,0);
}
void setup() {
// put your setup code here, to run once:
pinMode(6,INPUT);
pinMode(7,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(digitalRead(6) == LOW)
digitalWrite(7,HIGH);
else
digitalWrite(7,LOW);
}
Write code using the supplied keywords for arguments to these functions. It makes the code much easier for you to understand.
Right now this says, "If the pin 6 is LOW write pin 7 HIGH else write pin 7 LOW. You want to reverse those so that it is if the pin is LOW write pin 7 LOW else write pin 7 HIGH? Can you see now where to change it?
thanks for the advise. ill wright it like that from now on it will help.
that's working there. thanks for the help