top of page

 notes 

 1.0 TWO WAYS OF SENDING DATA 
      1) Send as series of bits / raw binary
      2) Send as ASCII-encoded


       Serial.println; 6-bit; 1023+return+new line; ASCII encoded-decima;
       Analog.Read; 10-bit
       Serial.Write; 10-bit; Raw binary; ASCII character

Lab #1: Intro to Asynchronous Serial Communications

Setup

Nano_2_pots_button_bb.png
IMG_7022_edited.jpg

Different data output

#1

WechatIMG1690.jpeg
WechatIMG1687.jpeg

Serial.println

6-bit, range from 0-1023

Those returned numbers are ASCII encoded-decimals

 

 

#2

WechatIMG1689.jpeg
WechatIMG1688.jpeg

Serial.write

10-bit, raw data

Those returned numbers are ASCII characters

 

 

#3

WechatIMG1691.jpeg
WechatIMG1692.jpeg
asciifull.gif

What's returned in the serial port matches each representation on the ASCII table.

ASCII Table

Formatting different data using 'Handshaking'

WechatIMG1706.jpeg

'Handshaking' is a 'call and response' method that the sender will only send when I told it to do so.

Description:

Initially, when I open the serial port, there are 'Hi' emerging on the port, meaning it is 'serial available'.

Then I type in any character, it returns three readings corresponding to three sensors. 

HOWEVER, each time I enter one character, it always returns two sets of readings. Why is that?

WechatIMG1708.jpeg

lab #2: Serial Input to P5.js

LabPotentiometerInNano_bb.png

Set up

This is a simple setup:

One potentiometer connected to the 3.3V power source, A0, and ground.

WechatIMG1698.jpeg
WechatIMG1709.jpeg

Connecting to p5.js

WechatIMG1699.jpeg

I typed in these codes as instructed. However, I don't think I fully understand these lines of code. I think I know what does each line mean, but if I am going to write the whole myself, I won't be able to do that. 

Anyways, hopefully in the future, I can get a deeper understanding of coding. 

The first pic shows when I was so struggled to get the port name from the console. It turned out that I did not open the P5 Serial Control. The last pic shows when the serial control was open, I was able to get the port name.

WechatIMG1700.jpeg

Make P5.js 'talk' (link)

WechatIMG1703.jpeg

P5.js with pull-down menu

WechatIMG1704.jpeg

Making graphs in P5.js (link)

Conclusion

WechatIMG1710.jpeg

I found this table to be really handy. I think it's very likely that I will use this table as a reference.

Set up

LabDigitalOutNano_bb.png
IMG_7025.heic

To set up, a 220-ohm resistor is connected to the LED. Arduino provides 3.3V to the LED and LED is also connected to D2 pin.

WechatIMG1713.jpeg

Program p5.js to control LED lightness (link)

WechatIMG1721.jpeg
ezgif.com-gif-maker.gif

Program p5.js to control LED lightness with data sent as a string (link)

ezgif.com-gif-maker (1).gif
ezgif.com-gif-maker.gif

Description:

As I drag the mouse, the position value in the p5 will be transferred to LED and change its brightness accordingly.

Description:

As I type in 'H' and 'L', the LED will turn on and off.

Conclusion

WechatIMG1753.jpeg
Hey Jeff, I add this section for you to leave any suggestions or comments. NO PRESSURE, you don't have to leave something : )

bottom of page