-
Notifications
You must be signed in to change notification settings - Fork 1
Sounds and Lights
Mr. James edited this page Sep 27, 2020
·
11 revisions
Plays a tone for a set duration from Cutebot's piezo speaker.
- tone (int) - the frequency of the tones/music notes you want to play
- duration (float) - the number of seconds you want to play the tone
You can play around with different tones. Below are some commonly used tones.
tone | note |
---|---|
262 | C4 |
294 | D4 |
330 | E4 |
349 | F4 |
392 | G4 |
440 | A4 |
494 | B4 |
cutebot.playTone(294, 0.5) # plays a C4 music note for half a second
cutebot.playTone(349, 1.0) # plays a F4 music note for one second
cutebot.playTone(440, 2.2) # plays a A4 music note for 2.2 seconds
Controls the two headlights.
-
whichLight (integer): there are four states to choose from
- 0 = Sets both lights to off
- 1 = Sets left light only
- 2 = Sets right light only
- 3 = Sets both lights
-
colors (array of three integers): RGB color that will be displayed
- colors[0] = red
- colors[1] = green
- colors[2] = blue
black = [0, 0, 0]
white = [255, 255, 255]
pink = [255, 192, 203]
red = [255, 0, 0]
cutebot.headlights(0, black) # turns off the headlights
cutebot.headlights(1, pink) # sets the left headlight to pink
cutebot.headlights(2, red) # sets the right headlight to red
cutebot.headlights(3, [80, 255, 80]) # sets both headlights to a light green color
Controls the two neopixels.
-
whichLight (integer): there are four states to choose from
- 0 = Sets both lights to off
- 1 = Sets left light only
- 2 = Sets right light only
- 3 = Sets both lights
-
colors (array of three integers): RGB color that will be displayed
- colors[0] = red
- colors[1] = green
- colors[2] = blue
black = [0, 0, 0]
white = [255, 255, 255]
pink = [255, 192, 203]
red = [255, 0, 0]
cutebot.headlights(0, black) # turns off the headlights
cutebot.headlights(1, pink) # sets the left neopixel to pink
cutebot.headlights(2, red) # sets the right neopixel to red
cutebot.headlights(3, [80, 255, 80]) # sets both neopixels to a light green color
Turns off all headlights and neopixels.
None
cutebot.lightsOff() # Turns off all LEDs.