Skip to main content

S4A (Scratch for Arduino) Project - A Keyboard Controlled Robot Car

A fun project to create a keyboard controlled robot car... based on the "Robotics: keyboard driven car"project on the S4A site. This to me, is a perfect example of an interdisciplinary project: there is quite a bit of mechanical, electrical and computer engineering involved. This project is being used by the Grade 5 kids in my child's school this year; the kids have been working with the Pro-Bot for quite a bit of time and I felt that letting them create their own robot car that behaves similar to the Pro-Bot is a great finale. So far, it's my favorite Arduino project. Below is a formal lesson plan for the robot car.

Note: This is a simplified version of the car from the S4A site - it just involves creating the keyboard driven car, minus the remote controller. This means the car stays connected to the laptop via the USB cable. 


Aim

Design your own robot car, whose movements can be controlled via the arrow keys on your keyboard. The car should move forward & backward, and turn left & right, controlled by the corresponding arrow keys.

Objective

The students learn to build a basic robot, using motors to drive its wheels and learn to control it via reactive programming.

Computer Science Concepts

  • Reactive programming
  • Conditionals
  • Forever loops

Classroom Standards


Materials

  • Software Development Environment: S4A
  • Arduino Uno
  • USB cable connecting the Arduino to the laptop
  • Bread board
  • 2 Servo Motors - continuous rotation (Parallax continuous rotation servos used here)
  • Wheels to attach to the Servos 
  • Batteries to power the servos (3 x 1.5 V AA, per servo)
  • 2 Battery holders
  • Jumper wires (easier if you color code them)
  • Sturdy base to attach the wheels, motors and the control unit 
  • Any extra materials needed for balancing the car structure, like the caster wheel used here
  • Other materials for constructing the car such as tape, etc. (velcro tape works well)

Time

2 hours approx.

Lesson Plan Links from S4A

The lesson plan developed by the S4A team is provided in the link below. It includes the S4A code for programming the car. We shall use Example 2: Robot Controlled with Keyboard:
http://vision.citilab.eu/visionwiki/index.php/Scratch_4_Arduino.html
http://vps34736.ovh.net/S4A/s4a-sample03.pdf
http://vps34736.ovh.net/S4A/s4a-protocol.pdf

Slides



Start off by introducing the students to the assignment & its requirements. The main job would be to introduce the students to the servo motor and its operation. Discuss what motors are & how they convert electrical energy into kinetic energy. Go through a few examples of where/how motors are seen/used in our daily lives. 

The pins used by S4A for the servos on Arduino are Digital 4 & Digital 7. Demonstrate to the students how the servo motor can move clockwise & anticlockwise, using the corresponding instructions on the S4A platform. It is helpful if the programming concepts used in this project - reactive programming & conditionals - are familiar to the students.

The students could spend some time assembling the car. A stable structure that can support the bread board, wheels, battery & the control unit needs to be built. A sturdy base should be used on which the Arduino & the breadboard can be mounted on top. There are several models of car chassis available on Amazon, specifically for mounting the Arduino boards, if you prefer to use those. Here, I have tried to create the car chassis out of pieces of wood... the reason being to let the kids see that they do have the option to assemble the car with simple materials, rather than a purchased kit.

Also, I used velcro tape to attach various components as needed to the base, so that they can be easily disassembled later on (a really important factor while sharing the materials among multiple classrooms). The caster wheel was attached with screws, for more stability. The same for the piece of wood holding the servos firmly to the base.

The servo motors could be mounted on the top or bottom portion of the base, such that the servo wires can be connected to the breadboard. A couple of battery packs would also be required to power the servos. I chose to go with the servos on the bottom of the wooden base. The wheels attached to the servos serve as the driver wheels, while a caster wheel that can turn in all directions makes up the front wheel. The battery packs are placed close to the breadboard to make the wiring easier. Note that we are not using a remote controlled version of the car here, hence the unit will still be connected via the USB cable to the laptop. Hence, you need to keep an eye out on how far your car moves.

Wiring

Color coding the jumper wires used for the connections would make it really easy for the kids to do the wiring. I have provided step-by-step wiring diagrams as part of the slides.






The Assembled Car...

Top view of the car
































Servo motor attached to a wheel





Caster wheel in front to balance the structure
Velcro Tape used to attach the various components easily to the base





Program the Car

The direction in which you get the servo motors to turn - clockwise or anticlockwise - controls the movement of the car. Use reactive programming to control the motor directions for up, down, left and right arrow keys. The complete program for the car is provided in the S4A lesson plan link. In fact, two options for programming the car are provided in the link...

I personally prefer Option 2 for this version of the car (attached to the laptop via the USB cable), as it operates only if a key is pressed.

Option 1
Option 2





















To summarize the class, discussing the working of the motors and the reactive programming used. Compare and contrast the two options provided for programming the car.

Comments

Popular posts from this blog

Arduino NANO 3X3X3 LED CUBE

DIY | 3X3X3 LED CUBE FOR ARDUINO NANO+ By   RGBFreak   in   Technology Arduino 17,143 146 22 Featured Download Favorite By   RGBFreak RGBFreak's YouTube Channel Follow More by the author: About: Hi there visitor! First of all thank you for checking out my profile! My name is Youri. I study Technical Computer Science in the Netherlands. I especially love the electronical part of my study. Since I l...   More About RGBFreak » Intro: DIY | 3x3x3 LED Cube for Arduino Nano+ Hi everyone! My name is RGBFreak and I created a YouTube channel quite recently. I love DIY and I especially love LED's, so that's why I decided to make my own 3x3x3 LED Cube! You will need the following items to make this LED Cube: • 27 single colored LED's. • Arduino Nano or one of his bigger brothers. • 3 NPN Transistors. I used the BC547. • 3 pin headers with 3 pins. • 1 pin header with 4 pins. • A piece of perfboard. • A few small cables. Ad

DIGITAL UV-METER, WITH OLED DISPLAY. ARDUINO PROJECT FOR BEGINNERS

DIGITAL UV-METER, WITH OLED DISPLAY. ARDUINO PROJECT FOR BEGINNERS By   techn0man1ac   in   Technology Arduino 4,792 87 13 Featured Download Favorite By   techn0man1ac Techn0man1ac blog Follow About: Techn0man1ac - техноманьяк   More About techn0man1ac » Intro: Digital UV-meter, With OLED Display. Arduino Project for Beginners Video demonstration (English subtitles). Hello,   instructable . Today I will tell you how to make a simple digital VU meter (sound level meter) using Arduino and OLED displays and 2 resistors by yourself (DIY). The device is quite simple, for beginners it will be a rewarding experience. Add Tip Ask Question Comment Download Step 1: Components for This Arduino Project: 3 More Images Arduino Nano V3.0; 0.96 inch IIC I2C 128X64 OLED Display; One 10K, resistor(R1 no scheme); One 10K-100K potentiometer(R2no scheme); Wires. Add Tip Ask Question Comment Download Step 2: Dev

Ultrasonic Distance Sensor in Arduino With Tinkercad

  Ultrasonic Distance Sensor in Arduino With Tinkercad Let's measure distances with an ultrasonic rangefinder (distance sensor) and Arduino's digital input. We'll connect up a circuit using a breadboard and use some simple Arduino code to control a single LED. You may have already learned to   read a pushbutton   and   PIR motion sensor   with Arduino's digital input, and we'll build on those skills in this lesson. Ultrasonic rangefinders use sound waves to bounce off objects in front of them, much like bats using echolocation to sense their environment. The proximity sensor sends out a signal and measures how long it takes to return. The Arduino program receives this information and calculates the distance between the sensor and object. Find this circuit on Tinkercad Explore the sample circuit embedded here by starting the simulation and clicking on the proximity sensor. This will activate a highlighted area in front of the sensor with a circle "