Page 58 - Ai Robogenius
P. 58

PROGRAMMING ARDUINO IN TINKERCAD

                  Once you connect sensors and components in Tinkercad, the next step is to program the Arduino.
                  Programming instructs the Arduino what to do — for example, when to turn on an LED or how to
                  respond to a sensor reading.
                  Tinkercad offers three programming modes that help both beginners and advanced learners
                  code easily.

                  Blocks Mode

                  This is the easiest mode for beginners. Instead of typing code, you drag and drop colourful blocks
                  that represent different commands. Each block performs a specific task and together they form
                  a program.

                  Types of Blocks
                  The types of blocks used in blocks mode are given below:

                       Type                     Description                                 Example

                   Output         Used to send signals or display results.   Turning an LED ON or OFF.


                   Control        Used to repeat actions or make             Loops like repeat, forever or if-else
                                  decisions.                                 statements.
                   Input          Used to take readings from sensors or      Reading data from a light or
                                  buttons.                                   temperature sensor.

                   Math           Used for calculations and                  Adding, subtracting or comparing two
                                  comparisons.                               sensor values.
                   Notation       Used to display text or numbers on         Showing Light Level = 200 on the
                                  the Serial Monitor.                        screen.
                   Variables      Used to store and reuse values.            Saving a sensor reading in a variable
                                                                             called sensorValue.

                  Blocks + Text Mode

                  This mode is a mix of both visual and written programming. When building a program using
                  blocks, Tinkercad automatically generates the C++ text code on the side.

                  This helps you  learn how block  commands  translate  into  real Arduino  code.  You  can switch
                  between blocks and text freely. It is perfect for students who are ready to move from visual coding
                  to text-based coding.

                  Text Mode

                  In this mode, you write full Arduino code manually using the C++ language. It gives complete control
                  over the project and is used for advanced programming. You type commands like digitalWrite(),
                  analogRead() and delay() directly.
                  Text-based programming is used when you want more flexibility, accuracy or to create complex
                  logic that may not be possible with blocks.


                                 AI RoboGenius - VII
                 56
   53   54   55   56   57   58   59   60   61   62   63