Need suggestions on shortening code; EEPROM is full!
Electricbees
Posts: 1
Working on a multi-task robot for a freshman class.
BOEbot is supposed to flash a sequence of 10 LED's (When lights are on, and the push button is not pressed)
It should also play a song and flash a different set of LEDs for when the button is pressed, and the lights are on.
Third, it plays a second song and a third sequence of lights for when the lights are off, regardless of button presses.
My coding is pretty brute-force in style, and I'm wondering if there is a way for me to cut down a lot of my lines?
Do lines/characters/commands fill up the EEPROM? I mean, does it store the same amount of data per line, command or character?
For playing a note with an LED, my code looks like this:
HIGH 7
HIGH 10
FREQOUT...............
LOW 7
LOW 10
Can I by chance, shorten those commands? Or make them store less memory on the EEPROM?
Attached is my .bs2 file.
Thanks for any suggestions!BOEBOTproject.bs2
BOEbot is supposed to flash a sequence of 10 LED's (When lights are on, and the push button is not pressed)
It should also play a song and flash a different set of LEDs for when the button is pressed, and the lights are on.
Third, it plays a second song and a third sequence of lights for when the lights are off, regardless of button presses.
My coding is pretty brute-force in style, and I'm wondering if there is a way for me to cut down a lot of my lines?
Do lines/characters/commands fill up the EEPROM? I mean, does it store the same amount of data per line, command or character?
For playing a note with an LED, my code looks like this:
HIGH 7
HIGH 10
FREQOUT...............
LOW 7
LOW 10
Can I by chance, shorten those commands? Or make them store less memory on the EEPROM?
Attached is my .bs2 file.
Thanks for any suggestions!BOEBOTproject.bs2
Comments
You can set up the LED sequences the same way with a table giving the sequence (assuming that the sequence advances with each note). Your music interpreter can also sequence through one of the LED tables as it advances from one note to another.
You'll need to describe in more detail what the songs are, what the LED sequences are, how these interact with the pushbuttons, etc.
The only thing that jumped out when I perused the code is that the initial 14 lines of OUTPUT and the 2 lines of INPUT could be handled by the DIRS command (check the manual). It will allow you to set the I/O state of pins with one command.
Toward the bottom of Loop1, there is another group of pins being set to all HIGH and a group to all LOW. This again could be handled the same.
Otherwise, the resident Forum Wizards may have something to say.
...I see Mr. Green has chimed in with very relevant insight.