Skip to content

mbof/sm11

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

This is a control sketch for the Kuman SM11 Arduino UNO car kit, using event-based programming to ensure responsiveness, and modularizing the code to increase readability and make it easier to create new control modes.

It does not fully implement the original software features. Currently implemented are the following:

  • Manual infrared control

  • Ultrasound obstacle-avoiding mode

  • Line-following mode

  • Object follow mode with infrared proximity sensor

  • (New) Pre-programmed "dances"

Currently unimplemented:

  • Bluetooth control

Download & Installation

  1. Clone or download this repository to your computer.

  2. Open the sketch file (sm11/sm11.ino) with the Arduino IDE

  3. Upload to your SM11 car kit using USB. (Don't forget to remove the Bluetooth module when uploading a sketch, as it seems to confuse the car.)

Usage

The car can be in different modes. To switch between modes, press the * key on the infrared remote control then the number of the mode, then the # key. When changing modes, a short beep will confirm each keypress. In any mode, using the directional keys (arrows) of the infrared remote control will also put the car back into manual mode.

There are currently 5 modes:

  1. Manual/dance mode (default): the car is controlled manually with the directional keys (arrows) of the infrared remote control. Keys from 0 to 9 will also let the car execute a series of predefined moves ("dance").

  2. Dance mode: the car will execute a series of predefined moves ("dance") when pressing any of the keys from 0 to 9 on the remote control. After executing a dance, the car will return to manual mode.

  3. Ultrasound mode: the car will move forward until detecting an obstacle with the ultrasound sensor (the forward-pointing yellow sensor at the front); when it encounters an obstacle, it will emit a short beep and make a right turn, then try moving forward again.

  4. Line-tracking mode: if the car is placed on a track consisting of a black line on white background, it will follow the black line by moving forward and adjusting its bearing left or right when its line-tracking sensors (downwards-pointing sensors close to the ground) detect that it's hitting the black line.

  5. Infrared follow mode: the car will advance until its front-facing infrared proximity sensors detect an object closeby. When removing the object, the car will therefore look like it's "following" it.

Architecture and how to extend

The architecture of the code is as follows:

  • The ControlContext class, defined in mode.cpp, takes care of high-level "executive" control of the car: which mode is it in, should it go forwards, backwards, or turn left, etc.

  • The modes themselves are implemented in the mode_manual.cpp, mode_dance.cpp, mode_ultrasound.cpp etc. Each mode provides at least two functions:

    • handle_ir_keypress(), which gets called each time a key is pressed on the infrared remote; and
    • control(), which gets called every loop regardless of infrared input.
  • The low-level outputs (motor & buzzer) are controlled in the Motor and Buzzer classes' respective control() functions, which are called once every loop. This is where pin output levels are actually set.

  • The loop first evaluates whether an infrared keypress has been received; if so, then it is passed to the control context for processing, which passes it on to the correct mode; then, it calls the control() method for the mode; finally it calls the control() method for the low-level controllers.

To extend the functionality, refer to this example commit which implements line-tracking functionality.

About

Control sketch for the Kuman SM11 Arduino UNO car

Resources

License

Apache-2.0, LGPL-2.1 licenses found

Licenses found

Apache-2.0
LICENSE
LGPL-2.1
LICENSE_IRremote.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors