Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
You are viewing an older revision! See the latest version
Homepage
TinyJS on mbed¶
what's this ?¶
TinyJS is an extremely simple (-2000 line) JavaScript interpreter engine.
I ported on mbed. but it restrict any features.
TinyJS project is https://code.google.com/p/tiny-js/
TinyJSは2000行以下で書かれた非常に小さいJavaScriptインタプリタエンジンです。これをmbedに移植してみました。
(ただし、いろいろ制限があります)
本家はこちら。 https://code.google.com/p/tiny-js/
functions¶
- mbed.DigitalIn(pinName, mode)
- mbed.DigitalOut(pinName, val)
- mbed.AnalogIn(pinName)
- mbed.AnalogOut(pinName, val)
- mbed.InterruptIn(pinName, edge, mode, callback)
- mbed.wait(s)
- mbed.timerStart()
- mbed.timerStop()
- mbed.timerReset()
- mbed.timerRead()
- mbed.Timeout(callback, t)
- mbed.memfree()
DigitalOut sample code
mbed.DigitalOut('LED1', 1);
mbed.DigitalOut('LED2', 0);
mbed.DigitalOut('LED3', 1);
mbed.DigitalOut('LED4', 0);
LED1 = 点灯、LED2=消灯、LED3=点灯、LED4=消灯
DigitalIn sample code
print(mbed.DigitalIn('p5', 'PullUp'));
p5をPullUpして読み、プリントする。
AnalogOut sample code
mbed.AnalogOut('p18', 0.8);
p18を 値0.8でアナログ出力する。
AnalogIn sample code
print(mbed.AnalogIn('p20'));
p20をアナログ入力し、プリントする。
Timeout and wait sample code
mbed.Timeout(function() {mbed.DigitalOut('LED1', 1);mbed.wait(3);mbed.DigitalOut('LED1', 0);}, 4);
LED1を4秒待って点灯して3秒後に消灯する。
movie sample¶
サンプル動画