An Arduino extension for Xcratch
This extension adds blocks to interact with Arduino boards connected via USB, allowing you to read sensor values and control actuators directly from Xcratch projects.
- Read Analog Inputs: Get values from analog sensors connected to pins A0-A5.
- Read Digital Inputs: Detect if a digital pin is HIGH or LOW.
- Control Digital Outputs: Set digital pins HIGH or LOW to control LEDs, relays, etc.
- Set Input Bias: Configure digital input pins with internal pull-up resistors.
- Control PWM Outputs: Set the duty cycle of PWM pins to control motor speed or LED brightness.
- Control Servo Motors: Set the angle of standard servo motors connected to digital pins.
Play Example Project to look at what you can do with the "Arduino" extension.
<iframe src="https://xcratch.github.io/editor/player#https://yokobond.github.io/xcx-arduino/projects/example.sb3" width="540px" height="460px"></iframe>This extension can be used with other extension in Xcratch.
- Open Xcratch Editor
- Click 'Add Extension' button
- Select 'Extension Loader' extension
- Type the module URL in the input field
https://yokobond.github.io/xcx-arduino/dist/xcxArduino.mjs
- Click 'OK' button
- Now you can use the blocks of this extension
npm install
Change vmSrcOrg
to your local scratch-vm
directory in ./scripts/setup-dev.js
then run setup-dev script to setup development environment.
npm run setup-dev
Run build script to bundle this extension into a module file which could be loaded on Xcratch.
npm run build
Run watch script to watch the changes of source files and bundle automatically.
npm run watch
Run test script to test this extension.
npm run test
Open this page from https://yokobond.github.io/xcx-arduino/
Contributions, issues and feature requests are welcome!
Feel free to check issues page.