Anonymous

Project:Nanode/Tiny Basic: Difference between revisions

From London Hackspace Wiki
no edit summary
No edit summary
 
Line 75: Line 75:
In just 30 seconds - anyone who remembers the early 1980s machines like the Spectrum will appreciate this is several times quicker.
In just 30 seconds - anyone who remembers the early 1980s machines like the Spectrum will appreciate this is several times quicker.


It should be straight forward to get the Nanode (Arduino) I/O pins accessible from basic keywords - perhaps something like defining each pin as a keyword
It should be straight forward to get the Nanode (Arduino) I/O pins accessible from basic keywords - perhaps something like defining each pin as a keyword.


to set Digital 4 High. As there are only 20 I/O pins on a ATmega - it's not going to take much program space to code them up. eg
As there are only 20 I/O pins on a ATmega - it's not going to take much program space to code them up. eg


10 DOUT 4 = 1            // Set Dig 4 High
10 DOUT 4 = 1            // Set Dig 4 High


20 Let A = AIN 1         // Get input from Analogue 1
20 DOUT 6 = LOW          // Set Dig 6 Low (alternative to 0) - Turns Nanode LED on...
 
30 Sleep 2000            // Wait 2 seconds
 
40 DOUT 6 = HIGH        // Turn off Nanode LED
 
50 Let A = AIN(1)        // Get input from Analogue 1 (reads 0 to 1023)
 
60 Print A
 
70 Let B = A / 4        // re-range it to 0-255
 
80 AOUT 5 = B            // set PWM (Analogue Write) on Dig 5


30 PRINT A


The Version of Tiny Basic  with these analogue and digital I/O extensions can be found on this [https://gist.github.com/1520899 Github Gist.]
The Version of Tiny Basic  with these analogue and digital I/O extensions can be found on this [https://gist.github.com/1520899 Github Gist.]
Notes : Current version only works on pins 0 to 9 - (ie not D10 - D13)


==List of KeyWords==
==List of KeyWords==
2

edits