Showing posts with label TinkerCAD. Show all posts
Showing posts with label TinkerCAD. Show all posts

Saturday, October 24, 2026

Exploring Serial Port Interactive Program Learning Activity || TinkerCAD Circuits Simulator - 03

 



 

Serial Port Interactive Program TinkerCAD Circuits Simulation Link

 <Code>

void setup()
{
Serial.begin(9600);
Serial.println("Who are you? enter b-boy or g-girl. ");
}
void loop()
{
if (Serial.available() > 0) {
int ans = Serial.read();
if ( ans == 'b')
Serial.println("You are boy.");
else if ( ans == 'g')
Serial.println("You are girl.");
else
Serial.println("Wrong answer.");
Serial.println("Who are you?enter b-boy or g-girl. ");
}
}

 



Here setup() function is used to set baud rate and print questions to the user on serial monitor; loop() function is having a logic part where it is checked whether serial data is available at board end, if yes then read it check it with specific character and print the proper reply. This process is repeated till the reset button is pressed.

 

The code prints questions on the Serial Monitor screen.

Who are you? enter b-boy or g-girl.

 

Type b inside the textbox situated top of serial window and press Send button. The Arduino program checks this response and replies as shown below.

You are boy.
Who are you? enter b-boy
or g-girl.

 

Type g inside the textbox situated top of the serial window and press Send button. The Arduino program checks this response and replies as shown below.

You are girl.
Who are you? enter b-boy
or g-girl.

 

Type c or any other letter inside the textbox situated top of serial window and press Send button. The Arduino program checks this response and replies as shown below.

Wrong answer.
Who are you? enter b-boy
or g-girl.

 


…till the next post, bye-bye & take care!

Friday, October 23, 2026

Exploring Hello World! - Once Learning Activity || TinkerCAD Circuits Simulator - 02

 


 


 

Hello World! Once TinkerCAD Circuits Simulation Link

 <Code>

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(
"Hello World!");
}
void loop() {
// put your main code here, to run repeatedly:
}

 



Here two code lines are added to setup() function, first one sets communication speed between Arduino Uno board and Host computer [baud rate:9600]; second line prints ‘Hello World!’ text on a new line.

To see the text line once again, you have to reset the Arduino Uno board [press the Stop & then Start Simulation]. So it is evident that the setup() function is used to set up the board or system and runs only once on every reset.



…till the next post, bye-bye & take care!

Thursday, October 22, 2026

Exploring Bare Minimum Learning Activity || TinkerCAD Circuits Simulator - 01

 



Bare Minimum TinkerCAD Circuits Simulation Link

 

The Arduino Uno R3 board is loaded with the default ‘L’ LED blink program, so when simulation starts 1st Arduino Uno R3 board’s ‘L’ LED starts blinking.

 

<Code>

// C++ code
//
void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  digitalWrite(LED_BUILTIN, HIGH);
  delay(1000);
// Wait for 1000 millisecond(s)
  digitalWrite(LED_BUILTIN, LOW);
  delay(1000);
// Wait for 1000 millisecond(s)
}

 

Whereas the 2nd Arduino Uno R3 board’s ‘L’ LED does not blink, because it is loaded with Bare Minimum code which does nothing & no tasks are added here.

 

Both Arduino boards Green Power LED glows when simulation is started, to indicate both are powered.

 

<Code>

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

 



As seen in the above flow chart, both setup() and loop() functions are blank or have no tasks so no output will be produced.

Even though the above code performs no function, it is useful for clearing out any old program.


 


…till the next post, bye-bye & take care!

Saturday, September 26, 2026

‘Learn Arduino Using TinkerCAD Circuits Simulator’ eBook’s Simulation & Resource Hyperlinks list page

 


…till the next post, bye-bye & take care!