You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-10Lines changed: 1 addition & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -112,35 +112,26 @@ The above code uses Socket.io to listen for a message from the HTML/JavaScript w
112
112
Using [Arduino Create](https://create.arduino.cc/editor) create the following sketch and upload it to your Arduino.
113
113
114
114
```csharp
115
-
// Define the port for the LED
116
115
intlightPin=2;
117
116
118
117
voidsetup()
119
118
{
120
-
// Initialize the light pin
121
119
pinMode(lightPin, OUTPUT);
122
-
123
-
// Initialize the Serial
124
120
Serial.begin(9600);
125
121
}
126
122
127
123
voidloop() {
128
124
129
-
// CHeck to see if Serial data is being received
130
125
if (Serial.available() >0) {
131
126
132
-
// Create a new string variable to receive Serial data
133
127
StringreceivedString="";
134
128
135
-
// Loop through received data and append to the receivedString variable
136
129
while (Serial.available() >0) {
137
130
receivedString+=char(Serial.read ());
138
131
}
139
132
140
-
// Print received Serial data
141
133
Serial.println(receivedString);
142
134
143
-
// Change LED status based on received data
144
135
if(receivedString=="1")
145
136
digitalWrite(lightPin,HIGH);
146
137
else
@@ -153,7 +144,7 @@ void loop() {
153
144
154
145
The previous code will listen to the serialport for an incoming message. Once a message is received, if the message is a one the light will turn on, if the message is a zero the light will turn off.
155
146
156
-
[View the Arduino code on Arduino Create](https://create.arduino.cc/editor/professoradam/da29d7ec-2df5-4528-82ce-817710aadb1a/preview)
147
+
[View the Arduino code on Arduino Create](https://create.arduino.cc/editor/professoradam/af5288bf-00cc-406c-844e-f20485fa2df8/preview)
157
148
158
149
You will need to setup the following circuit using your Arduino:
0 commit comments