You can control LEGO Power Function using Scrach as you can see on this video.
To achieve this follow these few steps:
- Download S4A (Scratch For Arduino)
- Download modified S4A firmware - 09 S4A LEGO IR Power Function.zip - I found it on this site.
- Optionally: to test if your Arduino board work witch S4A you can check original S4AFirmware.
- Extract files and copy three of them to directory named S4AFirmware14_LEGO_PF_IR:
- S4AFirmware14_LEGO_PF_IR.ino
- PowerFunctions.cpp
- PowerFunctions.h
I've changed pin from D5 to D12 (it depends on hardware)
int IR_pin = 12; // LEGO PF IR channel
- Use Arduino (or similar software) tu compile and upload S4AFirmware14_LEGO_PF_IR.ino (during uploading you have to close S4A because it can interrupt communication)
- Connect IR diode to pin (D12 in my case) - I've prepared simple board (in KiCAD) for Arduino Nano
Now You can make your first program:
it is a bit tricky: analog 5 mean "RED" channel and analog 6 mean "BLUE" one, values are
- 0 - float
- 1-7 forward (1-low, 7-fast)
- 100 - break
- 101-107 - reverse (101-low, 107-fast)
So this program does: FWD, wait 1s, Stop, wait 1s, REV, wait 1s, Stop, wait 1s for both channels/engines
Have fun!
Add comment