In this lab, I conducted different experiments in serial communication.

I was able to successfully do all the labs. But when I use portselector logic with my Windows PC system it goofs up the system and my computer doesn't run serial communication further. Possibly it doesn't close serial port on exiting the program from p5.js . I have run following codes by directly putting the value of the serial port in p5.js .

Seeing serial output on terminal on Windows 10

→ cmd ( To open Command Prompt )

>> powershell

>> [System.IO.Ports.SerialPort]::getportnames()

>> $port= new-Object System.IO.Ports.SerialPort COM#,Baudrate,None,8,one
// Replace COM port name & BaudRate

>> $port.open()

>> $port.WriteLine("some string")

>> $port.ReadLine()

>> $port.Close()

Lab1: Intro to Asynchronous Serial Communications

I am giving variable voltage analog input through potentiometer to analog input channels A0, A1 and pushbutton switch digital input to channel D2.

Schematic Diagram for Analog & Digital inputs to Arduino

Schematic Diagram for Analog & Digital inputs to Arduino

Asynchronous Serial Communication Analog & Digital Inputs

Asynchronous Serial Communication Analog & Digital Inputs

Program to print the Serial Output Data from the Arduino in ASCII, Binary, Hex, Dec forms

int analogValue0 = 0;      //Analog input from force sensor
int analogValue1 = 0;      //Analog input from photo transistor
int mappedValue0;

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);
  pinMode(2, INPUT);

}

void loop() {
  // put your main code here, to run repeatedly:

  //Read analog input from potentiometer
  analogValue0 = analogRead(A0); 
  analogValue1 = analogRead(A1); 
  mappedValue0 = map(analogValue0, 0, 1023, 0, 255);

  

  Serial.print(analogValue0);  
  //Found range (0-1023)
  Serial.print('\\t');
  Serial.print(mappedValue0);   
  Serial.print('\\t');
  Serial.write(mappedValue0); 
  Serial.print('\\t');
  Serial.print(mappedValue0, BIN);
  Serial.print('\\t');
  Serial.print(mappedValue0, HEX);
  Serial.print('\\t');
  Serial.print(mappedValue0, OCT);
  Serial.println(); 

}