Saturday, April 16, 2016

Play station Joystick test

#Basic code
clg
graphsize 500,500
font "arial",10,100
openserial 1, "COM3"
x=250
y=250
dx=0
dy=0
for a = 1 to 90000
n=asc (read(1))
if int (n/10)=1 then dx=-1
if int (n/10)=2 then dx=0
if int (n/10)=3 then dx=1
if int (n/10)=4 then dy=-1
if int (n/10)=5 then dy=0
if int (n/10)=6 then dy=1
x=x-dx
y=y+dy
circle x, y,2
next a







// Arduino code
 int x = 0;
 int y = 0;
 int F = 0;    
void setup()
{  Serial.begin(9600);
}
void loop()
{
  x = map(analogRead(1),0,1023,15,35);
  y = map(analogRead(2),0,1023,45,65);
  F = map(analogRead(0),0,1023,78,88);
  Serial.write(x);
  delay(10);
  Serial.write(y);
  delay(10);
  Serial.write(F);
  delay(10);
}

Thursday, April 14, 2016

Parametric Spirograph



















r=90
centerx=150
centery=150
rm=30
for n = 1 to 6
color rgb(int (rand*3)*127, int(rand*3)*127, int(rand*3)*127)
for t = 0 to 6.28 step .002
x=r*sin(t)+centerx
y=r*cos(t)+centery
xm=rm*sin(-t*3*n)+x
ym=rm*cos(-t*3*n)+y
circle xm,ym,1
next t
next n

Saturday, April 9, 2016

Graphing a sensor using Arduino


#Basic code
graphsize 900,300
font "arial",10,100
openserial 1, "COM4"
for window = 1 to 300
clg
for l = 25 to 325 step 25
line 30,l,900,l
text 0,l-5,5.5-int(l)/50+"V"
next l
for x = 1 to 900
pause .01
n=asc (read(1))
print n
circle x,277-2*n,2
next x
next window




// Arduino code
 int L = 0;
 int S = 0;         
void setup()
{  Serial.begin(9600); }

void loop()
{
  L = analogRead(2);
  S = map(L ,0,1023,0,127);
  //Serial.println(L); 
 Serial.write(S);       
  delay(50);
}

Friday, April 8, 2016

Hello World

# Creates a file and writes hellow world
# The file is in the same folder as the basic application
# Use notepad or word to open
open "blackboard.txt"
write "Hello world"