Brainfuck Interpreter on Arduino

Most likely, many who have studied programming heard about the Brainfuck language. Of these many, some implemented the interpreter of this language. I decided to build an interpreter based on the Arduino so that I could carry it with me and stuff the simplest programs on the road. Wait, you say, but on smartphones there are interpreters for every taste for a long time, why should you carry such a box with you? Because it's fucking awesome!



image



What I needed:



1. Arduino Pro mini;

2. LCD 16x2 i2c;

3. Four buttons;

4. Battery 18650;

5. Switch;

6. Wires;

7. Development board, on which to collect everything;

8. Box for housing.



Putting it all together. We hang the buttons on pins 2, 3, 4, 5. We connect the screen to A4 (SDA), A5 (SCL). For buttons, I do not use pull-up resistors (I use internal ones), maybe this is not good, but the parts are smaller, but for me this is more important. How to program pro mini read on the Internet. Nothing complicated. All the sketch code is on github .



A few moments. Yes, the handling of pushing buttons, taking into account the bounce of contacts, may not be the most successful, especially since β€œmagic numbers” are used - in short, gloom. The program has five modes:



0 - menu (by default), to display information about other modes and go to them;

1 - editing;

2 - performance;

3 - save to EEPROM;

4 - load from EEPROM.



When downloading a program from EEPROM, it can be edited (the dialed program will be replaced with the loaded one) and resave or execute.



image



Everything works for me from a 18650 battery, although the Arduin is five-volt. Good luck!



image







All Articles