Skip to content

Commit

Permalink
Renamed ino file
Browse files Browse the repository at this point in the history
  • Loading branch information
codeadamca committed Oct 29, 2020
2 parents 180db61 + 806dc28 commit e65a456
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 20 deletions.
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ Create an HTML file called `index.html`. Add the following code:
var socket = io();

socket.on('data', function(data) {
console.log(data);
document.getElementById('sample').style.opacity = data/100+"%";
console.log(data);
document.getElementById('sample').style.opacity = data+"%";
});

</script>
Expand Down Expand Up @@ -57,8 +57,20 @@ ls /dev/{tty,cu}.*
On a PC you can use the command line and the following command:

```
chgport
```

On my PC when I use the `chgport` command I get the following output:

```
AUX = \DosDevices\COM1
COM1 = \Device\Serial0
COM3 = \Device\Serial2
```

In my Node.js I would use `COM3` as my serialport string.

If you're not sure which one is your Arduino, just disconnet your Arduino and execute the cpommand again and take note of which port is no longer on the list.

Or you can find the name in [Arduino Create](https://create.arduino.cc/editor) in the drop down menu used to select your Arduino.

Expand Down Expand Up @@ -151,10 +163,10 @@ You will need to setup the following circuit using your Arduino:

## Launch Application

1. Using the Terminal start your Node.js app using `node app.js`.
2. Open up a browser and enter the URL `http://localhost:3000/`.
3. Using [Arduino Create](https://create.arduino.cc/editor) upload the sketch to your Arduino.
4. Turn the dial on the Arduino device and watch the red square in the browser.t.
1. Using [Arduino Create](https://create.arduino.cc/editor) upload the sketch to your Arduino.
2. Using the Terminal start your Node.js app using `node app.js`.
3. Open up a browser and enter the URL `http://localhost:3000/`.
4. Turn the dial on the Arduino device and watch the red square in the browser.

## Tutorial Requirements:

Expand Down
23 changes: 23 additions & 0 deletions arduino-to-node.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
int percent = 0;
int prevPercent = 0;

void setup() {

Serial.begin( 9600 );

}

void loop() {

percent = round(analogRead(0) / 1024.00 * 100);

if(percent != prevPercent) {

Serial.println(percent);
prevPercent = percent;

}

delay(100);

}
1 change: 1 addition & 0 deletions arduino_to_node.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
int percent = 0;int prevPercent = 0;void setup() { Serial.begin( 9600 ); }void loop() { percent = round(analogRead(0) / 1024.00 * 100); if(percent != prevPercent) { Serial.println(percent); prevPercent = percent; } delay(100); }
Expand Down
28 changes: 14 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,6 @@
<head>

<script src='https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js'></script>

<script>

var socket = io();

socket.on('data', function(data) {

console.log(data);

document.getElementById('sample').style.opacity = data+"%";

});

</script>

<style>

Expand All @@ -35,5 +21,19 @@ <h1>Communicating from an Arduino to Node.js</h1>

<div id="sample"></div>

<script>

var socket = io();

socket.on('data', function(data) {

console.log(data);

document.getElementById('sample').style.opacity = data+"%";

});

</script>

</body>
</html>

0 comments on commit e65a456

Please sign in to comment.