To open up the serial monitor, go up to tools and then select the serial monitor. Alternatively, CTRL+SHIFT+M will also bring up the same window. Make sure you are connected to the Arduino otherwise the window won't open up. myprepaidcenter
indianabent:
To open up the serial monitor, go up to tools and then select the serial monitor. Alternatively, CTRL+SHIFT+M will also bring up the same window. Make sure you are connected to the Arduino otherwise the window won't open up.
i know how to open Serial monitor, what i'm asking is how to make switch OFF on my code
UKHeliBob:
Read the state of the pin using digitalRead(). It will work even though it is set as an OUTPUT. If its state is HIGH, set it LOW else set it HIGH
UKHeliBob:
Read the state of the pin using digitalRead(). It will work even though it is set as an OUTPUT. If its state is HIGH, set it LOW else set it HIGH
int HIGH_PIN = 12;
int LOW_PIN = 5;
int i;
boolean c = 0;
char data;
void setup() {
Serial.begin(9600);
for (i = LOW_PIN; i <= HIGH_PIN ; i++) {
pinMode(i, OUTPUT);
pinMode(i, INPUT);
}
}
void loop() {
String command;
while (Serial.available() != 0) {
data = Serial.read();
command = command + data;
// command = Serial.readStringUntil('\n');
delay(10);
}
if (command.length() != 0) {
Serial.print("Command = ");
Serial.println(command);
}
int pin = command.toInt();
for (int i = LOW_PIN; i <= HIGH_PIN ; i++)
if (pin == i) {
digitalWrite(i, HIGH);
c = digitalRead(i) ;
}
if (pin == i) {
if (c == HIGH) {
digitalWrite(i, LOW);
}
}
}
may be a bit more of a hint - something like this:
selectedPinNumber = <whatever the end user entered>;
...
if (selectedPinNumber exists and its state is HIGH) then
set selectedPinNumber to LOW
else
set selectedPinNumber to HIGH
empty selectedPinNumber