My arduino uno was connected to a laptop with windows 10 and with the following code i could press a key on my keyboard in the serial monitor and the relay would close a circuit. Now i switched to a new computer and installed the latest version of arduino on my new laptop (windows 10) but the relay does not close a circuit any more. The main LED in it is turned on, and pressing a key on my keyboard only causes a quick flashing in the vcc LED.
int inByte = 0; // initialize the variable inByte
void setup() {
// put your setup code here, to run once:
pinMode(7, OUTPUT); //turn on the led bulb port
Serial.begin(9600); //
digitalWrite(7, HIGH);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available() > 0) { // check if any data received
inByte = Serial.read(); // yes, so read it from incoming buffer
if (inByte == '1') {
digitalWrite(7, HIGH);
}
else {
digitalWrite(7, LOW);
}
}
}
how were you sending the keys from the computer to the arduino? in the Serial Monitor?
did you set the baud rate to 9600? are you sending CR and LF also at the same time ? (should be set to none other with you send the '1' and the relay/whatever is on pin7 goes HIGH but right after you get CR and LF and the will go LOW)
Please correct your post above and add code tags around your code: [code]`` [color=blue]// your code is here[/color] ``[/code].
It should look like this:// your code is here
(Also press ctrl-T (PC) or cmd-T (Mac) in the IDE before copying to indent your code properly)