Programming the arduino
Here are the basics...
The microcontroller board used in the 2020 Bot is compatible with the Arduino family of microcontroller products based on the Atmel ATmega328. Specifically, we're using an Arduino Nano. Using an Arduino compatible board lets us take advantage of all the software and libraries written for these devices. You will need software running on your personal computer (Mac, Windows, or Linux) that allows you to write (or at least download) software for the Arduino Nano on the 2020 Bot.
Plenty of resources exist that help you get started with Arduino:
- Arduino Getting Started - https://www.arduino.cc/en/Guide/HomePage
- Instructable's Arduino Class - https://www.instructables.com/class/Arduino-Class
and many more (Google is your friend!)
The typical steps to follow are:
- Download and install the Arduino IDE from Arduino.cc
- You may need drivers to communicate with the Arduino Nano. Windows 10 folks are all set, but Mac users need this driver (https://github.com/adrianmihalko/ch340g-ch34g-ch34x-mac-os-x-driver).
- Download the .ZIP file for the Timer One Library from GitHub (https://github.com/PaulStoffregen/TimerOne)
- Download the .ZIP file for the 2020 Bot Library and Demo Code from GitHub (https://github.com/robojay/_2020Bot_Library)
- Start the Arduino IDE.
- Select Sketch->Include Library->Add .ZIP Library...
- Select the .ZIP file you downloaded for the Timer One Library
- Repeat for the .ZIP file you downloaded for the 2020 Bot Library
- Plug the 2020 Bot Arduino Nano into your computer via the USB cable
- Tell the Arduino software you are using a Nano by selecting Tools->Board->Arduino Nano
- Select your Arduino Nano's port under Tools->Port
- Load the Demo code by selecting File->Examples->_2020Bot_Library->_2020Bot_Demo
- Send it to the 2020 Bot by selecting Sketch->Upload
Although the Demo software shows off the 2020 Bot features, it is difficult for beginners to understand. I will be adding simpler examples to the 2020 Bot Library over time.
Running the Demo Code
The 2020 Bot Demo lets the robot be either remote controlled or operate in autonomous mode.
When you power on the robot, it starts in remote control mode. Pressing the arrow keys on the IR remote will drive the robot in the different directions. Pressing the "OK" button in the middle of the arrow keys will stop the robot. Don't hold the buttons down, just press and release. Each time forward or reverse is pressed, the robot will drive in that direction for a short time. While it's diving, you can always press another button (like OK to stop). The left and right buttons will have the robot pivot the robot in place just a little.
To start autonomous mode, press the # key on the remote. The robot will start wandering around, using it's IR LED and IR Receiver to detect obstacles. It's a simple sensor and won't always detect things. When the robot needs your help, press the * key to go back to remote control mode.