LAB

571666652011_.pic.jpg

Read the value from the first potentiometer, and print it to the Serial Monitor.

截屏2022-10-24 下午6.50.26.png

By typing ls -1 /dev/cu.*in Terminal, I got this:

elodieliu@ElodiedeMBP ~ % ls -1 /dev/cu.* 
/dev/cu.Bluetooth-Incoming-Port
/dev/cu.SB200
/dev/cu.usbmodem1201

There were 2 lines at first. Then I plugged the breadboard to my computer and typed againThe third line showed up.

When typing " screen /dev/cu.usbmodem1201 “, rolling numbers appeared, just like in the serial monitor.

Untitled

Serial.println() formats the value it prints as an ASCII-encoded decimal number.

(I turned the potentiometer to change the number from over 100 to around(below) 1024)

void setup() {
   // start serial port at 9600 bps:
   Serial.begin(9600);
}
 
void loop() {
   int analogValue = analogRead(A0);
   Serial.println(analogValue);
}

Untitled

Untitled

Untitled

^ changing the Serial.println()  to a Serial.write()

< map the output

Untitled

As I turned the potentiometer, the characters changed.

Untitled

the raw binary value

the ASCII-encoded binary value

the ASCII-encoded decimal

hexadecimal

octal values

Untitled

Untitled

Untitled