Bamduino ------- Bamduino is a small Biped Robot driven by two servos, powered by four AAA cells, controlled by a custom Arduino Uno circuit board. It has - one ultrasonic sensor module for detecting obstacles; two forward facing optical sensors (whiskers) for detecting obstacles; two downward pointing optical sensors (Beard) for detecting table edges etc.; one sounder; one red LED to indicate when recording commands; one expansion connector; a reset switch to toggle Bamduino's mode; one programming/communication connector. The two LEDs of the forward facing optical sensors glow dim when waiting for a command. Any particular one of the four sensor LEDs will stay on when avoiding a seen obstacle or table edge. Index ----- Bamduino programs Program descriptions #1 - #51 =============================================================================== Programs BambinoProMini |- B_PM01_ServosMid set servos to mid so horns can be put on in the right place |- B_PM02_BoardTest Servos to mid, flash LEDs, sound, test sensors |- B_PM03_BoardInit Initialise the EEPROM then make a sound from the speaker |- B_PM04_Servos calibrate and adjust the servo centres |- B_PM05_Rock example code for Bambino to rock from side to side |- B_PM06_Shuffle example code for Bambino to shuffle its feet |- B_PM07_WalkFd example code for Bambino to walk Forwards |- B_PM08_WalkStop a flag f_walking so Bambino on reset walks or stops |- B_PM09_Forward example code for a Forwards step |- B_PM10_Backward example code for a Backwards step |- B_PM11_TurnRight example code for a Right turn |- B_PM12_TurnLeft example code for a Left turn |- B_PM13_USsense Sense obstacles with the Ultrasonic sensor and avoid obstacles |- B_PM14_USwander Wander using the Ultasonic sensor to avoid obstacles |- B_PM15_BeardTest Test the Beard LEDs and sensors |- B_PM15_WhiskerTest Test the Whisker LEDs and sensors |- B_PM16_BeardWander Wander using the Beard to avoid table edges |- B_PM16_WhiskerWander Wander using the Whiskers to avoid obstacles |- B_PM17_Wander Wander avoiding table edges and obstacles |- B_PM18_AvoidBack a flag f_forwards so Bambino steps backwards when avoiding |- B_PM19_SpeedWander speed-up and speed-down |- B_PM20_Wander program split into Tab files |- B_PM21_PlayTime rock and shuffle routines |- B_PM22_BeAlive a routine to allow Bambino to act alive |- B_PM23_SerialCmnd commanding Bambino from the Serial Monitor or a serial terminal |- B_PM24_Learn learn and remember an Act |- B_PM25_Learn8 learn uo to 8 Acts |- B_PM26_CopyAct copy one Act to another |- B_PM27_loadAct load an Act directly from a serial terminal |- B_PM28_DumpActs Dump Acts to the PC |- B_PM29_Run8 autorun of Act 8 on reset or poweron, |- B_PM30_Wait w to Wait '1' - '9' seconds. |- B_PM31_Speed speed up/down, set speed |- B_PM32_CommanderXE Xplore, user Experiment |- B_PM33_PROGMEM Help text put in PROGMEM |- B_PM34_vbt commands for sound, vitality, turning skills |- B_PM35_Acts0 addition of a second memory page for Acts |- B_PM36_tx turn to light/dark, turn until at light/dark |- B_PM37_Mind print the robot's mind |- B_PM38_NewPrint ? - to print what is in the robot's brain |- B_PM39_Adjust b@ - to calibrate and Adjust the Serovo centres Bamduino |- BA40 common program for all arduino variants 14758 bytes |- BA41_Name # - assignment of robot Name and Group 16006 |- BA42_Autorun bax - to set the Autorun Act 16488 |- BA43_Go g0,g1 commands to disable,enable walking 16552 |- BA44_ReActs Reactions stored in EEPROM 18818 |- BA45_Behaviour 8 behaviours stored in EEPROM 24990 |- BA46_Aware background aware, bG,bW,bU 26098 |- BA47_Centre adjust of paceC and rollC 27008 |- BA48_Do Grouping of Acts into a Do 27284 |- BA49_Mind Grouping of commands into a Mind so the robot can randomly change its mind 27770 |- BA50_IR Control by IR 29712 |- BA51_actions.ino command 'a' to execute coded actions, chatter() 30676 |- BA552_IRout command 'T' to transmit by IR IR commands 30520 =============================================================================== // B_PM01_ServosMid // set servos to mid position so servo horns can be fitted in the correct orientation // servo pulse at mid position =1500 micro-seconds, equivalent to 90 degrees when using the Arduino Servo library // The Servo library is not used in order to avoid future interrupt conflicts. ------------------------------------------------------------------------------- // B_PM02_BoardTest // Set servos to mid positions - feet together, standing straight. // Flash the red LED, make a sound from the speaker, // flash the whisker and beard LEDs and measure light levels with the photo-transistors // and send the light values to the Serial Monitor. // The light values should vary and be between 0 and 1023 ------------------------------------------------------------------------------- // B_PM03_BoardInit // Initialise the EEPROM with default values // Then make a sound from the speaker, ------------------------------------------------------------------------------- // B_PM04_Servos // full instructions require a Duemilinova or bigger, ie ATmega328 or bigger /*Seting the servos with BM04_Servos ================================== This allows you to set the mid positions of both servos. When the servos are set to 90 degrees as in sketch BM01_ServosMid, because of the way each servo is made and the horns can only be put on about every 15 degrees, the feet may not be exactly side by side or flat on the ground. Load this sketch and open the Serial Monitor. Adjust the Roll servo so Bambino stands up straight and doesn't lean to the left or right. Adjust the Pace servo so Bambino stands with both feet side by side. The calibrated values are stored in EEPROM for further programs. Set servos to mid position - rollC and paceC, to check if feet are flat and feet together if not change rollC and paceC until they are Set the Pace length and Roll amount for walking. You can also set servos maximum and minimum safe angles for Roll Right and Roll Left, and Pace Left Forward and Left Back. Use the Arduino Serial Monitor set to 'no line ending', type I, *, -, +, /, C, R, P, S (or L, H) and press ENTER to send I, *, -, +, /, C, R, P, S (or L, H) Or use a Serial Terminal at 9600 baud. [I] to display instructions [*] to display current EEPROM values [-] adjust Servo position -ve [+] adjust Servo position +ve [/] to change servo. [C] to set Centre angles RollC and PaceC [R] to set the default Roll amount [P] to set the default Pace length [S] to set the servos at RollC and PaceC ([L] to set Low=Minimum angle - future use ) ([H] to set High=Maximum angle - future use ) instructions and current settings appear on screen. Servo values are in units of 1 degree nominal servo range is 0 to 180 with centre at 90 */ ------------------------------------------------------------------------------- // B_PM05_Rock // Stand in place and Rock from one foot to the other ------------------------------------------------------------------------------- // B_PM06_Shuffle // Stand in place and move feet backwards and forwards without lifting them. ------------------------------------------------------------------------------- // B_PM07_WalkFd // Walk forwards. ------------------------------------------------------------------------------- // B_PM08_WalkStop // You will have found that while Bambino is connected to the computer // there is no way to turn it off and stop it walking. // This sketch uses a flag f_walking to control whether the servos are // pulsed. Each time the Arduino awakes the value of the flag is toggled // between true and false. If the flag is true then the servo pins are // made output so the servos can be pulsed by the calls to ServoPulse. // Now by pressing the Reset switch you can stop Bambino walking and so // stop it walking off the table whilst you are loading a new sketch. // Experiment with altering rollspeed and pacespeed. ------------------------------------------------------------------------------- // B_PM09_Forward // To take a single step forwards Bambino needs to test which // foot is in front and then move the other one. To do this we // test paceat to see if it is less than paceC, if so then the // right foot is in front so Bambino should move the left foot. ------------------------------------------------------------------------------- // B_PM10_Backward // Walking backwards is the opposite of Forwards // To take a single step forwards Bambino needs to test which // foot is in front and then move the other one. To do this we // test paceat to see if it is less than paceC, if so then the // right foot is in front so Bambino should move the left foot. ------------------------------------------------------------------------------- // B_PM11_TurnRight // If each move ends with both feet flat on the ground then it doesn't // matter whether the next step is a step forward or a turn step. // void loop now has demonstration code for turning right. ------------------------------------------------------------------------------- // B_PM12_TurnLeft // If each move ends with both feet flat on the ground then it doesn't // matter whether the next step is a step forward or a turn step. // void loop now has demonstration code for turning left ------------------------------------------------------------------------------- // B_PM13_USsense // Bambino is fitted with an Ultrasonic Sensor to measure distances to objects. // By reading the sensor and taking action on the distance returned // Bambino can avoid obstacles. // A simple sample routine is given in void loop() // No routine is ever perfect, experiment with other actions. ------------------------------------------------------------------------------- // B_PM14_USwander // To better avoid obstacles three more routines are given // turnAway() turn away from the leading foot, so if the right foot is in front then turn left // turnMemory() turn the same way as last time // turnOther() turn the opposite way from last time ------------------------------------------------------------------------------- // B_PM15_BeardTest // Set servos to mid positions - feet together, standing straight. // flash the beard LEDs and measure light levels with the photo-transistors // and send the light values to the Serial Monitor. // The light values should vary and be between 0 and 1023. // Tungsten light levels fluctuate at 100Hz for 50Hz supply and 120Hz for 60Hz supply. // A 100Hz fluctuation repeats ever 10ms and 120Hz repeats every 8.3ms. // Reading are taken every 1ms for a total of 8ms, // and the max is taken of all the readings against the previous reading // so a peak light level will be included in the readings. // This gives a consistent light level reading. // // Make sure the Beard LEDs shine just in front of the feet and not on the feet. // Make sure the Beard photosensors are aimed at the light spots from the Beard LEDs. // When Bambino is on white paper there should be a big difference between the // light and dark readings. // Darker surface will give smaller differences. // When Bambino is at the edge of a table and the LEDs shine to the floor there // should be only a small difference between the light and dark readings. // In later sketches if the difference is <10 then Bambino thinks it is at an edge. // The threshold of 10 can be changed as you wish. ------------------------------------------------------------------------------- // B_PM15_WhiskerTest // Set servos to mid positions - feet together, standing straight. // flash the whisker LEDs and measure light levels with the photo-transistors // and send the light values to the Serial Monitor. // The light values should vary and be between 0 and 1023. // Tungsten light levels fluctuate at 100Hz for 50Hz supply and 120Hz for 60Hz supply. // A 100Hz fluctuation repeats ever 10ms and 120Hz repeats every 8.3ms. // Reading are taken every 1ms for a total of 8ms, // and the max is taken of all the readings against the previous reading // so a peak light level will be included in the readings. // This gives a consistent light level reading. // // Make sure the Whisker LEDs shine forwards and slightly out. // Make sure the Whisker photosensors are aimed in the same direction. // When Bambino is not in front of an object and there is no reflected light there // should be only a small difference between the light and dark readings. // In later sketches if the difference is >20 then Bambino thinks there is an obstacle. // The threshold of 20 can be changed as you wish. ------------------------------------------------------------------------------- // B_PM16_BeardWander // Use the Beard LEDs and sensors to detect table edges // while walking ------------------------------------------------------------------------------- // B_PM16_WhiskerWander // Use the Whisker LEDs and sensors to detect obstacles while walking // in QueryObstacle() note change of comparison from < for holes to > for obstacles // holes are indicated by no light being reflected, hence threshold ------------------------------------------------------------------------------- // B_PM17_Wander // Use the Beard LEDs and sensors and ultrasonic sensor to detect table edges and obstacles // Ultrasonic routine from B_PM14_USwander incorporated in avoidUObjects() ------------------------------------------------------------------------------- // B_PM18_AvoidBack // You must have noticed that when running B_PM17_Wander that // when avoiding obstacles or holes and turning right or left // Bambino steps forward and sometimes walks into an obstacle // or falls off the table! // Here is introduced f_forwards, set in forward() and backward() // which controls the step direction in turnRight() and turnLeft). // Now when avoiding Bambino will step back. ------------------------------------------------------------------------------- // B_PM19_SpeedWander // Animals including humans tend to slow down when they encounter an obstacle // and to speed up when there are no obstacles // two new functions are defined speedup() and speeddown() // speeddown() reduces the roll and pace speeds each time it is called until each speed==1 // speedup () increases the roll and pace speeds each time it is called until each speed==maxspeed ------------------------------------------------------------------------------- // B_PM20_Wander.ino /* B_PM20_Wander sketch group is functionally identical to B_PM19SpeedWander.ino The sketch was getting long and now all the basic functions are there it has been split into sections with each section in a separate file. When B_PM20_Wander, the main sketch file, is loaded into the Arduino IDE it loads the other files into Tabs. The declarations have been moved to .h Header files which at compile time the IDE includes at the #include "filename.h" statements, - note that these simple header files use "" unlike Libraries which use <>. Also an unchanging part of Setup() has been moved to Init.h. The functions have been moved to .ino files which at compile time the IDE adds, in alphabetical order, to the end of this sketch file. It is not advisable to put declarations of pins, constants or variables in those .ino files since the declarations must be before where they are referenced. So keep declarations in the .h Header files.*/ ------------------------------------------------------------------------------- // B_PM21_PlayTime.ino /* Now Bambino can move about and sense obstacles we can get it come alive. Two new routines rock() and shuffle() allow loop() to have Bambino Wander for a few steps then rock then wander again then shuffle. Routines whee() and whoa() give Bambino a better voice. Build some routines for yourself. */ ------------------------------------------------------------------------------- // B_PM22_BeAlive.ino /* By using a switch statement with a random number as the case variable Bambino can be made to do sequences which don't repeat and it seems to have a mind of its own and looks alive. Note RightStep(repeat) and LeftStep(repeat) which help it from getting stuck. Experiment with different values for the min and max in random(). You could write similar functions to RightStep(repeat) and LeftStep(repeat) for turnAway(), turnMemory(), turnOther() and add them to the switch list. If you do, remember to increase the random range for the case variable. */ ------------------------------------------------------------------------------- // B_PM23_SerialCmnd.ino /* There has to be a better way of telling Bambino what to do than keep modifying this sketch. Here we start by sending commands to bambino from the Serial Monitor, or any terminal program. The commands are 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'S' - Stop/Start toggle reset flag stopped/walking 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash. */ ------------------------------------------------------------------------------- // B_PM24_Learn.ino /* We can store in EEPROM a sequence of the commands used in B_PM23_SerialCmnd, then replay it. These moves will be remembered even with power off. The whiskerLEDs glowing dim indicate Bambino is ready for a command. The redLED on indicate Bambino is recording commands. The commands are '.',[Esc] - quit current operation - recording, playing 'S' - Stop/Start 'P' - Play moves Act, if included in a recording will restart the Act 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r' - Record moves into EEPROM 'p' - Print moves in Act '?' - print instructions If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). Upper-case is used for single letter commands and Lower-case will be used for parameter commands. The Act slot has 32 bytes and can have up to 31 commands with the last entry '.' indicating end of Act. Until recording mode is entered any of the commands have immediate effect. In immediate mode keys 'P' will play Act, whatever has been recorded. If 'r' is entered then the Act will start to be recorded. Bambino will 'bip' each time a command is entered in record mode. Any of the keys can be entered in recording mode including 'r' but that makes no sense and is blocked during recording as is 'p' by setting f_recordC to false. 'S','?' operate but are also blocked from being recorded by setting f_recordC to false. eg r,F,F,R,R,P,. records FFRRP. in the Act if in immediate mode 'P' is entered then the Act will be played giving Forward, Forward, turnRight, turnRight, Play so the Act will repeat until '.' or Esc is keyed. */ ------------------------------------------------------------------------------- // B_PM25_Learn8.ino /* We can store in EEPROM sequences of the commands used in B_PM23_SerialCmnd, then replay them. If each sequence which we will call an Act takes less than 32 commands then 8 routines will fit in the second 256 byte page of the EEPROM. The whiskerLEDs glowing dim indicate Bambino is ready for a command. The redLED on indicate Bambino is recording commands. The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' '?' - print instructions If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). Upper-case is used for single letter commands and Lower-case is used for parameter commands. Each Act slot has 32 bytes and can have up to 31 commands with the last entry set to 0 indicating end of Act. Until programming mode is entered any of the commands have immediate effect. In immediate mode keys 1 - 8 will play the corresponding Act, whatever has been recorded. If 'r' is entered then the next key must be 1 - 8 to select the Act to be recorded. If '.' is entered instead then recording will not start. Any of the keys can be entered in recording mode including 'r' but that makes no sense and is blocked during recording as is 'p' by setting f_recordC to false. 'S','?' operate but are also blocked from being recorded by setting f_recordC to false. When recording has started keys 1 - 8 will record a jump to the corresponding Act. However in record mode playback of that Act is suppressed, hence after entering an Act number it makes no sense to add more commands since they will never get done because control will jump to the new Act; so just enter '.', or '.' to quit recording. eg r,1,F,F,R,R,1,Q or r,1,F,F,R,R,1,. records FFRR1. in Act1 if in immediate mode '1' is entered then Act1 will be played giving Forward, Forward, turnRight, turnRight, jump to Act 1 So Act 1 will play forever, Act 1 could also be invoked from another Act eg r,2,1,Q here Act 2 does nothing except jump to Act 1. '.' or Esc quits a playing Act. */ ------------------------------------------------------------------------------- //B_PM26_CopyAct.ino // Binary sketch size: 10,796 bytes (of a 30,720 byte maximum) /* Introducing the command 'c','1'-'8','1'-'8' - copy one Act to another Act slot so 'c25' will copy Act 2 to Act 5, overwriting all of Act 5 In loop() - Recording: if(f_newRec && Ccmnd=='.') {f_recording =false; } // '.',Esc from GetKey() @ case 'r' allows quit recording after keying 'r' but before keying an Act number. The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM27_loadAct.ino // Binary sketch size: xx,xxx bytes (of a 30,720 byte maximum) /* Introducing the command 'l','1'-'8' - load an Act directly from Serial Monitor without acting "l8VVVFFV." loads Act 8 with "VVVFFV." You can load command strings which won't Play or do odd things , so beware. E.g. keys 18PVV. will load PVV. into Act 8, but after P the VV will never be done. E.g. l8VVp8VV. will load VVp8VV. and when played Bambino plays VV then does 'p' and wants an Act number to print, when the Act is printed the EEPROMindex will point to the end of the printed Act so Play will end when that is read. However if . is entered instead of an Act number then the '8' after 'p' will be read and Act 8 will be done again The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM28_DumpActs.ino // Binary sketch size: 11,596 bytes (of a 30,720 byte maximum) /* Introducing the command D to dump all Acts the the PC without names or length information. The output from D can be copied from the Serial Monitor, saved to a file, edited and pasted back into the Serial Monitor and loaded into Bambino. Load with 'l' load '1' - '8'. If the Acts are short all can be pasted ay once. Otherwise load one Act at a time to prevent overloading the Aduino serial buffer. As before - You can load command strings which won't Play or do odd things , so beware. E.g. keys 18PVV. will load PVV. into Act 8, but after P the VV will never be done. E.g. l8VVp8VV. will load VVp8VV. and when played Bambino plays VV then does 'p' and wants an Act number to print, when the Act is printed the EEPROMindex will point to the end of the printed Act so Play will end when that is read. However if . is entered instead of an Act number then the '8' after 'p' will be read and Act 8 will be done again The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM29_Run8.ino // Binary sketch size: 11,596 bytes (of a 30,720 byte maximum) /* Introducing autorun of Act 8 on reset or poweron, set in the #define below so it is easy to alter. Walking/Stopped still operates as before. The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM30_Wait.ino // Binary sketch size: 11,596 bytes (of a 30,720 byte maximum) /* Introducing the command 'w' ' to wait '1' - '9' seconds. GetCcmnd: and Record: made into functions to better handle command parameters The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'w','1'-'9' - wait 1 - 9 seconds. 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM31_Speed.ino // Binary sketch size: 12,650 bytes (of a 30,720 byte maximum) /* Introducing 'su' - speedup, speed is increased by 1 'sd' - speed down, speed is divided by 2 's', '1'-'9' set speed speeds set by 'su' and 's' are max'd to rollspeedmax and pacespeedmax and min'd to 1 'sr','1'-'9' set roll speed 'sp','1'-'9' set pace speed 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'P' now also prints behaviour variables The commands are '.',[Esc] - quit current operation - recording, playing, input 'S' - Stop/Start 'P' - Print moves in all Acts, and behaviour variables 'D' - Dump out all acts to the PC, same as 'P' but without the Act and moves numbers. '1'-'8' the routine or Act to record or replay 'F' - Forwards one step 'B' - Backwards one step 'R' - turn Right one step 'L' - turn Left one step 'H' - Halt with both feet together 'V' - Voice, make a beep 'U' - read Ultrasonic sensor and react to objectRange using avoidUObjects() behaviour rules 'W' - read Whisker sensors and avoid holes (if any) using avoidObstacles() behaviour rules 'G' - read Beard sensors and avoid obstacles (if any) using avoidHoles() behaviour rules 'A' - beAlive() until reset // the loop() from B_M22_BeAlive 'w','1'-'9' - wait 1 - 9 seconds. 'su' - speedup, speed is increased by 1 up to max 'sd' - speed down, speed is divided by 2 down to 1 's','1'-'9' set speed, both roll and pace speeds set to the same 'sr','1'-'9' set roll speed 'sp','1'-'9' set pace speed 'sm' - set rollspeedmax to current rollspeed, set pacespeedmax to current pacespeed 'srm' - set rollspeedmax to current rollspeed 'spm' - set pacespeedmax to current pacespeed 'r','1'-'8' - Record moves into selected Act in EEPROM 'p','1'-'8' - Print moves in selected Act '1' - '8' 'c','1'-'8','1'-'8' - copy one Act to another Act slot 'l','1'-'8' - load Act, like 'r' but records commands into EEPROM without playing them '?' - print instructions The whiskerLEDs glowing dim indicate Bambino is ready for a command. If other keys are pressed, including lower case keys, then the Whisker LEDs will flash badkey(). */ ------------------------------------------------------------------------------- //B_PM32_CommanderXE.ino /* Introducing 'X' to Xplore which just calls Wander() 'E' Experiment - call your own routines */ ------------------------------------------------------------------------------- //B_PM33_PROGMEM.ino // Binary sketch size: 12,826 bytes (of a 30,720 byte maximum) /* Sooner or later it had to happen that due to the peculiar(stupid) way the Arduino moves all undefined strings to RAM the program runs out of RAM, so before we can add to the printHelp() messages we need to put the text in PROGMEM. See http://arduino.cc/en/Reference/PROGMEM To use PROGMEM we need to do #include Put the help text strings in program memory, build a table to index the strings then amend printHelp() to read the strings. */ ------------------------------------------------------------------------------- //B_PM34_vbt.ino // Binary sketch size: 13,720 bytes (of a 30,720 byte maximum) /* Introducing 'v', 'b','e','o' choose sound: 'b' bip, 'e' whee, 'o' whoa 'b', 'p','1'-'9' set behave paceby - step length 't','1'-'9' set behave turnby - step length in turns 'r','1'-'9' set behave rollby - roll amount when stepping A new Tab file skills34.ino for 't', 'a' - turn Away from leading foot, 'm' - turn Memory (same way as last turn, 'o' - turn Other way from last time these will be used in avoid Acts */ ------------------------------------------------------------------------------- //B_PM35_Acts0.ino // Binary sketch size: 14,022 bytes (of a 30,720 byte maximum) /* Introducing Acts page 0 Eight Acts is not a lot and the Arduino has four 256 byte EEPROM pages. The existing eight Acts only use one of the four pages. One page has initialisation data and one other page will have the rules specifying what to do if the Ultrasonic or optical sensors see something, at present these rules are hard coded in the program but it would be good if they could be changed as easily as the Acts. We can use EEPROM page 2 for eight more Acts leaving page 3 available for the sensor rules. There needs to be a simple way of addressing these next eight Acts. Decoding multi digit numbers involves parsing the numbers from the rest of the commands in the Act and would add complexity. An easier way is if the second set of eight Acts are in logical page 0 and an Act number for these Acts starts with 0 giving Acts 01 to 08, then if a zero is read the next number addresses an Act in page 0. If this logical page 0 is actually in page 3 of the EEPROM then this will work. So far no command starts with the number 0 or 9, we could have had Acts 91 to 98 but I prefer 01 to 08. So 05 would address Act 5 in page 0 and so would ..0FFR5 etc. */ ------------------------------------------------------------------------------- //B_PM36_tx.ino // Binary sketch size: 14,904 bytes (of a 30,720 byte maximum) /* Introducing tl - turn to light using the whisker light sensors td - turn to dark using the whisker light sensors t@l - turn until @ light using the whisker light sensors t@d - turn until @ dark using the whisker light sensors */ ------------------------------------------------------------------------------- //B_PM37_Mind.ino // Binary sketch size: 15,168 bytes (of a 30,720 byte maximum) /* Introducing M - print current Behaviour, BeHaves in Mind (RAM values) */ ------------------------------------------------------------------------------- //B_PM38_NewPrint.ino // Binary sketch size: 15,370 bytes (of a 30,720 byte maximum) /* Introducing ?h print Help ?p print Page ?x print Act ?? print current Act ?b print Behaviour ?m print Mind Removed 'P' 'M' 'D' 'p' */ ------------------------------------------------------------------------------- //B_PM39_Adjust.ino // Binary sketch size: 17,730 bytes (of a 30,720 byte maximum) /* Re-introducing Adjust Servos of Prog4 invoked here by b@ */ ------------------------------------------------------------------------------- //BA40.ino //#define BambinoPM //#define BambinoMM #define BambinoM2 // Binary sketch size: 17,584 bytes (of a 30,720 byte maximum) /* == Notes ==================================================== Common program for all Arduino Bambinos No additional changes. /* ------------------------------------------------------------------------------- //BA41_Name.ino // Binary sketch size: 18,966 bytes (of a 30,720 byte maximum) /* == Notes ==================================================== Introducing b# Set the robot Name, where Name can be any character b#<'0'-'9'> Set the robot Group 0 - 9 bq robot turns off Debug messages f_BeQuiet - disable print messages if true f_MsgForMe - read but ignore messages if true f_hashcmnd - waiting for the second byte of a # command so don't Play f_hashhashSTOP - ## Stop from external commander so stop command doesn't get overwritten by GetCommand hashhashAt - remember EEPROMindex at hashhashSTOP boolean Quit() //check for Quit - simplifies checking for Quit Introducing message prefixes #0 all the following commands are for every robot, all robots turn off Debug messages # all the following commands are for the Named robot, other robots are silent # all the following commands are for the Group, robots are silent ## (default) robots stop and obey all commands and send Debug messages robots remember what they were doing in hashhashAt useful to talk to an unknown robot or put all in the stopped state #< robots do their Default Act #> robots resume their Act from hashhashAt #? all robots reply with their name and group - delayed according to name /* ------------------------------------------------------------------------------- //BA42_Autorun.ino // Binary sketch size: 19,440 bytes (of a 30,720 byte maximum) /* == Notes ==================================================== Introducing ba<0-8> = set Act to Autorun on PowerOn or Reset, 0 means no autorun ba9 = set Autorun act to run when there is nothing else to do Bugfix If S was used to disable walking by turning off the servos and further walking c ommands given then the actual feet positions no longer agreed with rollat and paceat so when the servos were re-enabled a jerk often occurred. The new variables Srollat and Spaceat are used to remember rollat and paceat when S is used to turn off walking and rollat and paceat are set to Srollat and Spaceat when walking is re-enabled. */ ------------------------------------------------------------------------------- //BA43_Go.ino // Binary sketch size: 19,532 bytes (of a 30,720 byte maximum) /* == Notes ==================================================== Previously there was no way to set walking on or off specifically except by the # commands. 'S' demands a human look at the robot and send 'S' as appropriate to make the robot walk or stop. Introducing g0 - turn off walking g1 - turn on walking */ ------------------------------------------------------------------------------- //BA44_ReActs.ino // Binary sketch size: 21,344 bytes (of a 30,720 byte maximum) //set Serial terminal to 9600 baud /* == Notes ==================================================== Previously Reactions were hard coded in the program which meant they couldn't be altered as easily as writing a new Act. Behaviour parameters are stored in EEPROM page 0, Acts are stored in EEPROM pages 1 and 2, Acts in page 1 and Acts0 in page 2 Which leaves EEPROM page 3 spare. Reactions will now be stored in EEPROM page 3 which will allow easy experimentation with different Reactions. There are 8 slots available and they are allocated as Reaction-1 - Reaction if Ultrasonic distance is less than 'aware at' value hence objects farther away than 'aware at' value are ignored Reaction-2 - Reaction if Ultrasonic distance is less than 'too close' value i.e. objects are too close Reaction-3 - Reaction if both Left and Right Whiskers sense an object Reaction-4 - Reaction if Left Whisker senses an object Reaction-5 - Reaction if Right Whisker senses an object Reaction-6 - Reaction if both Left and Right Beard sensors detect a hole Reaction-7 - Reaction if Left Beard sensor detects a hole Reaction-8 - Reaction if Right Beard sensor detects a hole Introducing ! to change to EEPROM page 3, Reactions, in the same way as 0 changes to Acts page 0. Reactions can be recorded or loaded just like Acts. !r1 - records Reaction-1 etc. !1 - plays Reaction-1 etc l!1 or !l1 - loads Reaction-1 etc bum+ - set manually SonarAwareAt, units 50mm/2inch bum- - set manually SonarTooNear, units 50mm/2inch bu+,0-9 - set SonarAwareAt, units 50mm, distance beyond which objects are ignored bu-,0-9 - set SonarTooNear, units 50mm, distance at which objects are too near bus - save current Sonar settings to EEPROM */ ------------------------------------------------------------------------------- //BA45_Behaviour.ino // Binary sketch size: 28,434 bytes (of a 30,720 byte maximum) ProMini // Binary sketch size: 28,434 bytes (of a 32,256 byte maximum) UNO M2 /* == Notes ==================================================== Introducing Previously there was just on behaviour with various behaviour parametes. Now there are eight behaviours taking up all of the first 255 bytes of EEPROM and just as with Acts each behaviour takes up 32 bytes. b,1-8 - set behaviour slot and copy contents to current behaviour in RAM bs,1-8 - save current behaviour to a slot bl,1-8 - load a behaviour slot, with ,,.... behavior-number =0 ends parameter is ,#, etc. depends on Terminal software used. eg bl4 30,85. load slot 4 position 30 with 85 and quit loading eg bl5 30,85,20,2. load slot 5 position 30 with 85 and position 20 with 2 and quit loading ?B - print all Behaviour slots as a table */ ------------------------------------------------------------------------------- //BA46_Aware.ino // Binary sketch size: 29,980 bytes (of a 30,720 byte maximum) ProMini // Binary sketch size: 30,076 bytes (of a 32,256 byte maximum) UNO M2 /* == Notes ==================================================== Introducing Being Aware bG<0,1> - automatic sense Ground, 0=off, 1=on bW<0,1> - automatic sense Whiskers, 0=off, 1=on bU<0,1> - automatic sense Ultrasonic, 0=off, 1=on These commands set up automatic sensing and reacting before each new command (except when recording) They add another state to the program so now there are recording, playing, reacting and aware. */ ------------------------------------------------------------------------------- //BA47_Centre.ino // Sketch uses 25662 bytes (83%) of program storage space. Maximum is 30720 bytes. ProMini Arduino 1.8.2 // Sketch uses 25662 bytes (79%) of program storage space. Maximum is 32256 bytes. UNO M2 Arduino 1.8.2 /* == Notes ==================================================== Introducing Cr+,Cr- (0-9) - alter rollC in current mind in RAM - offset from rollC in current behaviour in EEPROM Cp+,Cp- (0-9) - alter paceC in current mind in RAM - offset from paceC in current behaviour in EEPROM This gives an easier way to see the effects of rollC and paceC offsets than using b@ to Adjust Servos */ ------------------------------------------------------------------------------- //BA48_Do.ino // Sketch uses 25906 bytes (80%) of program storage space. Maximum is 32256 bytes. UNO M2 Arduino 1.8.2 // Sketch uses 25906 bytes (84%) of program storage space. Maximum is 30720 bytes. ProMini Arduino 1.8.2 /* == Notes ==================================================== Introducing ( - start of a Do, a jump to an Act will on . continue in the Do will show its location in EEPROM when played. If a jump is made to an Act which contains another Do then that Do will become the current Do and the old Do will be forgotten. ) - end of a Do will show its location in EEPROM when played Q or [Esc] to Quit all, needed to quit from a Do b0 - reload current behaviour to RAM BeHaves */ ------------------------------------------------------------------------------- //BA49_Mind.ino // Sketch uses 28018 bytes (91%) of program storage space. Maximum is 30720 bytes. ProMini Arduino 1.8.2 // Sketch uses 26808 bytes (83%) of program storage space. Maximum is 32256 bytes. UNO MM Arduino 1.8.9 // Sketch uses 28018 bytes (86%) of program storage space. Maximum is 32256 bytes. UNO M2 Arduino 1.8.9 == Notes ==================================================== Introducing m - start of a mind } - end of a Mind m will give an ability for the robot to randomly change its mind depending on a probability level 1 - 9 where e.g. 7 will give 70% certainty of the commands in the mind being executed and 30% probability of them being skippped and execution continuing after the }. use - m4FFFVRRR}BBB. if a generated random number (1 - 9) is less than 4 then FFFVRRR will be skipped ------------------------------------------------------------------------------- //BA50_IR.ino char thisrobot[] ="Bambino"; char thisprog[] ="BA50_IR"; //PM Sketch uses 29798 bytes (96%) of program storage space. Maximum is 30720 bytes. //PM Global variables use 1136 bytes (55%) of dynamic memory, leaving 912 bytes for local variables. Maximum is 2048 bytes. //M2 Sketch uses 28886 bytes (89%) of program storage space. Maximum is 32256 bytes. //M2 Global variables use 1136 bytes (55%) of dynamic memory, leaving 912 bytes for local variables. Maximum is 2048 bytes. //set Serial terminal to 9600 baud //== #define ================================================ //#define BambinoPM //ProMini 328,5v #define BambinoMM //Uno with no Whisker sensors, Malcolm Margolis PCB //#define BambinoM2 //Uno, Malcolm Margolis PCBv2 //== Introducing ========================================== //Control by IR ------------------------------------------------------------------------------- //BA51_actions.ino char thisrobot[] ="Bambino"; char thisprog[] ="BA51_actions"; //PM Sketch uses 30652 bytes (96%) of program storage space. Maximum is 30720 bytes. //PM Global variables use 1133 bytes (55%) of dynamic memory, leaving 919 bytes for local variables. Maximum is 2048 bytes. //M2 Sketch uses 30676 bytes (89%) of program storage space. Maximum is 32256 bytes. //M2 Global variables use 1133 bytes (55%) of dynamic memory, leaving 919 bytes for local variables. Maximum is 2048 bytes. //set Serial terminal to 9600 baud //== #define ================================================ //#define BambinoPM //ProMini 328,5v //#define BambinoMM //Uno with no Whisker sensors, Malcolm Margolis PCB #define BambinoM2 //Uno, Malcolm Margolis PCBv2 //== Introducing ========================================== // command 'a' to execute coded actions - as - shuffle(), ar - rock(), ax beeps // chatter() make random sounds // *r, *w read and write any byte in EEPROM - for higher processor =============================================================================== //BA52_IRout.ino char thisrobot[] ="Bambino"; char thisprog[] ="BA52_IRout"; //PM Sketch uses 30496 bytes (96%) of program storage space. Maximum is 30720 bytes. //PM Global variables use 1131 bytes (55%) of dynamic memory, leaving 919 bytes for local variables. Maximum is 2048 bytes. //M2 Sketch uses 30520 bytes (89%) of program storage space. Maximum is 32256 bytes. //M2 Global variables use 1211 bytes (55%) of dynamic memory, leaving 919 bytes for local variables. Maximum is 2048 bytes. //set Serial terminal to 9600 baud //== #define ================================================ //#define BambinoPM //ProMini 328,5v #define BambinoMM //Uno with no Whisker sensors, Malcolm Margolis PCB //#define BambinoM2 //Uno, Malcolm Margolis PCBv2 //== Introducing ========================================== // command 'T' to tell an IR cmnd // command 'n' to nap for tenths seconds ===============================================================================