stickOS & cui32stem

http://www.seeedstudio.com/depot/customize-your-grove-kit-p-931.html?cPath=138

http://cpustick.com/stickos.htm

 

基于PIC的控制系统,内置StickOS,支持串口连接直接basic编程(这个比arduinoIDE响应快速得多,而且能看到源码),兼容arduino

 

闪个灯,led插在电池口旁边的Gnd和D0上,

 

  10 dim led as pin rd0 for analog output
  20 dim fade
  30 let led = 1000
  40 let fade = 1
  50 while 1 do
  60   if led>=1000||led<=0 then
  70     let fade = fade*-1
  80   endif
  90   let led = led+fade*10
 100   sleep 10 ms
 110 endwhile
  

 

i2c三轴加速器模块

http://www.seeedstudio.com/wiki/Grove_-_I2C_3-axis_Accelerometer

 

  10 dim acc
  20 let acc = 0x4c
  30 dim MODE as byte, MODE_STANDBY as byte, MODE_ACTIVE as byte
  40 let MODE = 0x7, MODE_STANDBY = 0x0, MODE_ACTIVE = 0x1
  50 dim SR as byte, config as byte
  60 let SR = 0x8, config = 0x7
  70 i2c start acc
  80 i2c write MODE, MODE_STANDBY
  90 i2c write SR, config
 100 i2c write MODE, MODE_ACTIVE
 110 dim rsp[3] as byte, x[6] as short
 120 while 1 do
 130   i2c read rsp
 140   i2c stop
 150   let x[0] = rsp[0]&0x20>>5, x[1] = rsp[0]&0x1f
 160   let x[2] = rsp[1]&0x20>>5, x[3] = rsp[1]&0x1f
 170   let x[4] = rsp[2]&0x20>>5, x[5] = rsp[2]&0x1f
 180   print x
 190   sleep 1000 ms
 200 endwhile

 

 

你可能感兴趣的:(OS)