Valiant robots
In this workshop, you will use the new Sensor Board circuit in TinkerCAD to enhance your text programming skills through a series of challenges from bronze to silver levels. The challenges involve taking readings from sensors, controlling LEDs based on sensor inputs, and even incorporating temperature sensors and potentiometers for more advanced programming exercises. By completing the exercises, you will gain practical experience in building and programming robots virtually. Each challenge introduces new concepts and builds upon the previous ones, offering a gradual learning curve for beginners and enthusiasts alike.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Valiant robots Week 4 exercises
Building and Programming robots in TINKERCAD This week you be using new Sensor Board circuit available classroom activity in TinkerCAD. This workshop aims to revise and practice your text programming skills. Please complete the bronze requirements before starting the silver, and complete the silver before starting the gold.
BRONZE Challenge: Aim: Take readings from the LDR sensor and use them to change the brightness of the Red LED Steps: 1. Setup the LDR and Red LED ready to use. Remember to specify one as INPUT and the other as OUTPUT Component Pin number LDR A5 Red LED 3
BRONZE Challenge: Steps: 2. In your loop() function, take a reading from the LDR and store it in a variable 3. Print the value of the variable to the serial monitor Remember, you will need to add Serial.begin(9600); to your setup() function to start the serial monitor 4. Run the simulation to find the minimum and maximum values generated by the LDR
BRONZE Challenge: Steps: 3. Use the map function to convert the sensor reading from the LDR to the range for the LED (0-255) Remember to store the output from the map function to use later 4. Use analogWrite(pin, value) to set the brightness of the Red LED
SILVER Challenge: Extending your program from Bronze: Aim: Use the temperature sensor, with the potentiometer to control when the heating comes on. The heating being on will be indicated by the Blue LED, whilst a comfortable temperature will be indicated with the Green LED. If it is too hot, the Green LED will flash Component Pin number Temperature sensor A4 Potentiometer A3 Green LED 5 Blue LED 6
SILVER Challenge: Steps: Setup the three components ready to use Map the values from the temperature sensor into degrees C (-40 to 125 ) Print the current temperature to the serial monitor If the temperature is more than 20 , the Green LED should turn on If the temperature is more than 50 , the Green LED should flash on and off as a warning
SILVER Challenge: Steps: Map the values from the potentiometer to a suitable range for controlling the heating, e.g. (5 to 35 ) Print the result of the mapping to the Serial monitor Add a condition that compares the result of the temperature sensor mapping to the result of the potentiometer mapping If the temperature (in ) is less than the setting of the potentiometer, turn on the Blue LED
GOLD Challenge: Aims: Using the motion sensor (PIR sensor) turn on the outside light (Light Bulb). The Tilt sensor is used to activate a security system that will flash the RGB LED if too much force is applied or something is detected too close by the ultrasonic sensor Component Pin number PIR sensor 4 Light bulb 12 Tilt sensor 2 RGB LED Red 9 RGB LED Green 10 RGB LED Blue 11 Ultrasonic Trigger (output) 7 Ultrasonic Echo (input) 8
GOLD Challenge: Steps: Add the following function for using the ultrasonic to your program: Remember you may need to rename the variables used to refer to the pins
GOLD Challenge: Both the tilt and the motion sensors provide digital input instead of analog input. We can therefore use them as follows: bool motion = digitalRead(pirPin); if(motion){ // motion detected } Steps: If motion is detect turn out the light bulb, otherwise turn it off
GOLD Challenge: Steps: Write a function void checkSecurity() In the new function, get readings from the force sensor and the distance on the ultrasonic If any force is detected, the brightness of the RGB LED Red colour should be set based on the force If the ultrasonic detects anything, the brightness of the RGB LED Blue colour should be set based on the distance The RGB LED should flash with the R and B values above alternating, and a fixed G value
GOLD Challenge: Steps: In your main loop, if tilt sensor is tilted, call the newly defined checkSecurity() function
Extension Challenge: What else can you add to this program? The soil sensor has not been used yet. This could be used to decide when to water a plant or open a window. Add a servo to the circuit and use the soil sensor to control the servo Remember to add #include <Servo.h> at the top of your program, then Servo myServo; . In setup(), initialise the servo with servo.attach(servoPin); then set the angle of the servo with servo.write(180);