atduskgreg-rad 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +104 -0
- data/License.txt +282 -0
- data/Manifest.txt +142 -0
- data/README.rdoc +55 -0
- data/Rakefile +142 -0
- data/bin/hello_world_test/Makefile +436 -0
- data/bin/hello_world_test/hello_world.cpp +23 -0
- data/bin/rad +302 -0
- data/lib/examples/add_hysteresis.rb +13 -0
- data/lib/examples/basic_blink.rb +10 -0
- data/lib/examples/blink_m_address_assignment.rb +104 -0
- data/lib/examples/blink_m_hello.rb +14 -0
- data/lib/examples/blink_m_multi.rb +61 -0
- data/lib/examples/blink_with_serial.rb +16 -0
- data/lib/examples/configure_pa_lcd_boot.rb +91 -0
- data/lib/examples/debounce_methods.rb +49 -0
- data/lib/examples/external_variable_fu.rb +26 -0
- data/lib/examples/external_variables.rb +32 -0
- data/lib/examples/first_sound.rb +23 -0
- data/lib/examples/frequency_generator.rb +30 -0
- data/lib/examples/hello_array.rb +48 -0
- data/lib/examples/hello_array2.rb +79 -0
- data/lib/examples/hello_array_eeprom.rb +59 -0
- data/lib/examples/hello_clock.rb +84 -0
- data/lib/examples/hello_eeprom.rb +51 -0
- data/lib/examples/hello_eeprom_lcdpa.rb +81 -0
- data/lib/examples/hello_format_print.rb +94 -0
- data/lib/examples/hello_lcd_charset.rb +75 -0
- data/lib/examples/hello_pa_lcd.rb +59 -0
- data/lib/examples/hello_servos.rb +88 -0
- data/lib/examples/hello_spectra_sound.rb +38 -0
- data/lib/examples/hello_world.rb +11 -0
- data/lib/examples/hello_xbee.rb +12 -0
- data/lib/examples/hysteresis_duel.rb +39 -0
- data/lib/examples/i2c_with_clock_chip.rb +124 -0
- data/lib/examples/midi_beat_box.rb +86 -0
- data/lib/examples/midi_scales.rb +94 -0
- data/lib/examples/motor_knob.rb +30 -0
- data/lib/examples/servo_buttons.rb +23 -0
- data/lib/examples/servo_calibrate_continuous.rb +92 -0
- data/lib/examples/servo_throttle.rb +40 -0
- data/lib/examples/software_serial.rb +10 -0
- data/lib/examples/sparkfun_lcd.rb +48 -0
- data/lib/examples/spectra_soft_pot.rb +34 -0
- data/lib/examples/times_method.rb +8 -0
- data/lib/examples/toggle.rb +10 -0
- data/lib/examples/twitter.rb +57 -0
- data/lib/examples/two_wire.rb +14 -0
- data/lib/libraries/AFSoftSerial/AFSoftSerial.cpp +321 -0
- data/lib/libraries/AFSoftSerial/AFSoftSerial.h +61 -0
- data/lib/libraries/AFSoftSerial/keywords.txt +18 -0
- data/lib/libraries/AF_XPort/AF_XPort.cpp +166 -0
- data/lib/libraries/AF_XPort/AF_XPort.h +48 -0
- data/lib/libraries/DS1307/DS1307.cpp +162 -0
- data/lib/libraries/DS1307/DS1307.h +66 -0
- data/lib/libraries/DS1307/keywords.txt +18 -0
- data/lib/libraries/FrequencyTimer2/FrequencyTimer2.cpp +144 -0
- data/lib/libraries/FrequencyTimer2/FrequencyTimer2.h +42 -0
- data/lib/libraries/FrequencyTimer2/keywords.txt +22 -0
- data/lib/libraries/I2CEEPROM/I2CEEPROM.cpp +120 -0
- data/lib/libraries/I2CEEPROM/I2CEEPROM.h +70 -0
- data/lib/libraries/I2CEEPROM/keywords.txt +21 -0
- data/lib/libraries/LoopTimer/LoopTimer.cpp +35 -0
- data/lib/libraries/LoopTimer/LoopTimer.h +34 -0
- data/lib/libraries/LoopTimer/keywords.txt +27 -0
- data/lib/libraries/OneWire/OneWire.cpp +194 -0
- data/lib/libraries/OneWire/OneWire.h +63 -0
- data/lib/libraries/OneWire/keywords.txt +35 -0
- data/lib/libraries/OneWire/readme.txt +13 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.cpp +296 -0
- data/lib/libraries/SWSerLCDpa/SWSerLCDpa.h +69 -0
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.cpp +311 -0
- data/lib/libraries/SWSerLCDsf/SWSerLCDsf.h +67 -0
- data/lib/libraries/Servo/Servo.cpp +192 -0
- data/lib/libraries/Servo/Servo.h +61 -0
- data/lib/libraries/Stepper/Stepper.cpp +220 -0
- data/lib/libraries/Stepper/Stepper.h +86 -0
- data/lib/libraries/Stepper/keywords.txt +28 -0
- data/lib/libraries/Wire/Wire.cpp +262 -0
- data/lib/libraries/Wire/Wire.h +67 -0
- data/lib/libraries/Wire/keywords.txt +31 -0
- data/lib/libraries/Wire/twi.h +57 -0
- data/lib/libraries/Wire/utility/twi.c +449 -0
- data/lib/libraries/Wire/utility/twi.h +57 -0
- data/lib/plugins/bitwise_ops.rb +54 -0
- data/lib/plugins/blink.rb +25 -0
- data/lib/plugins/blink_m.rb +356 -0
- data/lib/plugins/debounce.rb +138 -0
- data/lib/plugins/debug_output_to_lcd.rb +71 -0
- data/lib/plugins/hysteresis.rb +52 -0
- data/lib/plugins/input_output_state.rb +84 -0
- data/lib/plugins/lcd_padding.rb +58 -0
- data/lib/plugins/mem_test.rb +37 -0
- data/lib/plugins/midi.rb +60 -0
- data/lib/plugins/parallax_ping.rb +50 -0
- data/lib/plugins/servo_pulse.rb +31 -0
- data/lib/plugins/servo_setup.rb +86 -0
- data/lib/plugins/smoother.rb +54 -0
- data/lib/plugins/spark_fun_serial_lcd.rb +100 -0
- data/lib/plugins/spectra_symbol.rb +79 -0
- data/lib/plugins/twitter_connect.rb +145 -0
- data/lib/rad.rb +5 -0
- data/lib/rad/README.rdoc +5 -0
- data/lib/rad/arduino_plugin.rb +246 -0
- data/lib/rad/arduino_sketch.rb +627 -0
- data/lib/rad/generators/makefile/makefile.erb +243 -0
- data/lib/rad/generators/makefile/makefile.rb +38 -0
- data/lib/rad/hardware_library.rb +813 -0
- data/lib/rad/init.rb +14 -0
- data/lib/rad/progressbar.rb +236 -0
- data/lib/rad/rad_processor.rb +128 -0
- data/lib/rad/rad_rewriter.rb +94 -0
- data/lib/rad/rad_type_checker.rb +26 -0
- data/lib/rad/sim/arduino_sketch.rb +57 -0
- data/lib/rad/sketch_compiler.rb +47 -0
- data/lib/rad/tasks/build_and_make.rake +210 -0
- data/lib/rad/tasks/rad.rb +2 -0
- data/lib/rad/todo.txt +13 -0
- data/lib/rad/variable_processing.rb +153 -0
- data/lib/rad/version.rb +9 -0
- data/scripts/txt2html +67 -0
- data/setup.rb +1585 -0
- data/spec/examples/hello_world.rb +11 -0
- data/spec/examples/serial_motor.rb +12 -0
- data/spec/models/arduino_sketch_spec.rb +82 -0
- data/spec/models/sketch_compiler_spec.rb +96 -0
- data/spec/models/spec_helper.rb +2 -0
- data/spec/sim/hello_world_spec.rb +42 -0
- data/spec/spec.opts +1 -0
- data/test/test_array_processing.rb +179 -0
- data/test/test_plugin_loading.rb +151 -0
- data/test/test_translation_post_processing.rb +185 -0
- data/test/test_variable_processing.rb +238 -0
- data/website/examples/assembler_test.rb.html +73 -0
- data/website/examples/gps_reader.rb.html +39 -0
- data/website/examples/hello_world.rb.html +38 -0
- data/website/examples/serial_motor.rb.html +41 -0
- data/website/index.html +178 -0
- data/website/index.txt +64 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +169 -0
- data/website/template.rhtml +48 -0
- metadata +217 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
class MidiScales < ArduinoSketch
|
2
|
+
|
3
|
+
# purpose
|
4
|
+
# trigger midi output with buttons and
|
5
|
+
# spectra soft pots
|
6
|
+
#
|
7
|
+
#
|
8
|
+
|
9
|
+
|
10
|
+
@current_note = int
|
11
|
+
@last_note_one = 0
|
12
|
+
@last_note_two = 0
|
13
|
+
@last_note_three = 0
|
14
|
+
@note = int
|
15
|
+
|
16
|
+
input_pin 1, :as => :sensor_one, :device => :spectra
|
17
|
+
input_pin 2, :as => :sensor_two, :device => :spectra
|
18
|
+
input_pin 3, :as => :sensor_three, :device => :spectra
|
19
|
+
input_pin 7, :as => :button_one, :device => :button
|
20
|
+
input_pin 8, :as => :button_two, :device => :button
|
21
|
+
input_pin 9, :as => :button_three, :device => :button
|
22
|
+
output_pin 13, :as => :led
|
23
|
+
|
24
|
+
serial_begin :rate => 31250
|
25
|
+
|
26
|
+
def setup
|
27
|
+
delay 3000
|
28
|
+
end
|
29
|
+
|
30
|
+
def loop
|
31
|
+
change_tone if button_one.read_input
|
32
|
+
change_pressure if button_two.read_input
|
33
|
+
change_channels if button_three.read_input
|
34
|
+
read_sensor_one
|
35
|
+
read_sensor_two
|
36
|
+
read_sensor_three
|
37
|
+
end
|
38
|
+
|
39
|
+
def change_tone
|
40
|
+
110.upto(127) do |note|
|
41
|
+
play 0, note, 127
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def change_pressure
|
46
|
+
110.upto(127) do |pressure|
|
47
|
+
play 0, 45, pressure
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def change_channels
|
52
|
+
0.upto(6) do |channel|
|
53
|
+
play channel, 50, 100
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def read_sensor_one
|
58
|
+
@current_note = sensor_one.soft_lock
|
59
|
+
pre_play(@current_note, @last_note_one, 13)
|
60
|
+
@last_note_one = @current_note
|
61
|
+
end
|
62
|
+
|
63
|
+
def read_sensor_two
|
64
|
+
@current_note = sensor_two.soft_lock
|
65
|
+
pre_play(@current_note, @last_note_two, 14)
|
66
|
+
@last_note_two = @current_note
|
67
|
+
end
|
68
|
+
|
69
|
+
def read_sensor_three
|
70
|
+
@current_note = sensor_three.soft_lock
|
71
|
+
pre_play(@current_note, @last_note_three, 15)
|
72
|
+
@last_note_three = @current_note
|
73
|
+
end
|
74
|
+
|
75
|
+
def pre_play(current_note, last_note, channel) # warning, don't use last as a parameter...
|
76
|
+
n = 1 + channel
|
77
|
+
unless current_note == last_note
|
78
|
+
@note = ((current_note /16) + 40)
|
79
|
+
play_with_no_delay( channel, @note, 100 )
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def play(chan, note, pressure)
|
84
|
+
note_on(chan, note, pressure)
|
85
|
+
delay 100 # adjust to need
|
86
|
+
note_off(chan, note, 0)
|
87
|
+
end
|
88
|
+
|
89
|
+
def play_with_no_delay(chan, note, pressure) # note is not turned off
|
90
|
+
note_on(chan, note, pressure)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class MotorKnob < ArduinoSketch
|
2
|
+
|
3
|
+
# ----------------------------------------------------------
|
4
|
+
# MotorKnob adapted from Tom Igoe's Arduino Sketch
|
5
|
+
#
|
6
|
+
# Brian Riley - Underhill Center, VT, USA July 2008
|
7
|
+
# <brianbr@wulfden.org>
|
8
|
+
#
|
9
|
+
# A stepper motor follows the turns of a potentiometer
|
10
|
+
# (or other sensor) on analog input 0.
|
11
|
+
#
|
12
|
+
# http://www.arduino.cc/en/Reference/Stepper
|
13
|
+
# ----------------------------------------------------------
|
14
|
+
|
15
|
+
fourwire_stepper 8, 9, 10, 11, :as => :mystepper, :speed => 31, :steps => 200
|
16
|
+
input_pin 0, :as => :sensor
|
17
|
+
|
18
|
+
|
19
|
+
@previous = "0, int"
|
20
|
+
@value = "0, int"
|
21
|
+
|
22
|
+
def loop
|
23
|
+
|
24
|
+
@value = analogRead(sensor)
|
25
|
+
mystepper.set_steps @value - @previous
|
26
|
+
@previous = @value
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class ServoButtons < ArduinoSketch
|
2
|
+
|
3
|
+
# original syntax
|
4
|
+
input_pin 6, :as => :button_one, :latch => :off
|
5
|
+
# preferred syntax
|
6
|
+
input_pin 7, :as => :button_two, :device => :button
|
7
|
+
input_pin 8, :as => :button_three, :device => :button
|
8
|
+
output_pin 13, :as => :led
|
9
|
+
output_pin 2, :as => :my_servo, :device => :servo
|
10
|
+
|
11
|
+
|
12
|
+
def loop
|
13
|
+
check_buttons
|
14
|
+
servo_refresh
|
15
|
+
end
|
16
|
+
|
17
|
+
def check_buttons
|
18
|
+
read_and_toggle button_one, led
|
19
|
+
my_servo.position 180 if read_input button_two
|
20
|
+
my_servo.position 60 if read_input button_three
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
class ServoCalibrateContinuous < ArduinoSketch
|
2
|
+
|
3
|
+
# ----------------------------------------------------------------------
|
4
|
+
# Program to calibrate a 'continuous' or 'modified' hobby servo
|
5
|
+
#
|
6
|
+
# Basically uses teh servo 'spped' command to send a speed
|
7
|
+
# of zero (0) to the servo continuously. You then use a small
|
8
|
+
# screwdriver to adjust the potentiometer on the sero until there
|
9
|
+
# is no motion whatsoever.
|
10
|
+
#
|
11
|
+
# The program strats off by commanding max speed clockwise and then
|
12
|
+
# counter clockwise. First the LED blinks rapidly for 2 seconds as
|
13
|
+
# a warning that motion is coming. Then the LED is turned on solid
|
14
|
+
# Then 2 seconds max rev clockwise, then two seconds max rev counter-
|
15
|
+
# clockwise. Then the LED is turned off and this followed by twenty
|
16
|
+
# second of the servo commanded to zero (0) speed. During this time
|
17
|
+
# you may adjust the servo for no motion. If you stilll have more
|
18
|
+
# adjustmenst to make you will be warned by the flashing LED to
|
19
|
+
# back off while it moves back and forth. This full speed motion
|
20
|
+
# is to let you knwo you have it right,
|
21
|
+
#
|
22
|
+
# The 20 second timer uses the Arduino millis() counter which
|
23
|
+
# rolls over after a couple million milliseconds. I made no attempt
|
24
|
+
# to allow for ths. If your servo isn't calibrated after a couple
|
25
|
+
# million milliseconds and the prgram jams up then (a) hit the reset
|
26
|
+
# button, or (b) give up!
|
27
|
+
#
|
28
|
+
# Brian Riley - Underhill Center, VT, USA July 2008
|
29
|
+
# <brianbr@wulfden.org>
|
30
|
+
#
|
31
|
+
# ----------------------------------------------------------------------
|
32
|
+
|
33
|
+
|
34
|
+
@test_state = "2, int"
|
35
|
+
@cycle_time = "0, long"
|
36
|
+
|
37
|
+
|
38
|
+
# This sets up to do four units at once
|
39
|
+
# You can comment the extra lines out or leave them in, if there's nothing
|
40
|
+
# connected, no harm, no foul!
|
41
|
+
output_pin 12, :as => :servo4, :device => :servo, :minp => 400, :maxp => 2600
|
42
|
+
output_pin 11, :as => :servo3, :device => :servo, :minp => 400, :maxp => 2600
|
43
|
+
output_pin 10, :as => :servo2, :device => :servo, :minp => 400, :maxp => 2600
|
44
|
+
output_pin 9, :as => :servo1, :device => :servo, :minp => 400, :maxp => 2600
|
45
|
+
|
46
|
+
output_pin 13, :as => :led
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
def loop
|
51
|
+
if @test_state == 2
|
52
|
+
|
53
|
+
40.times { blink led, 50 } # 40 x 50 ms is a 2 second blinking light
|
54
|
+
# ** Warning! ** "... danger Will Robinson!"
|
55
|
+
toggle led # turn it on keep it on -- keep hands away
|
56
|
+
servo1.speed -90
|
57
|
+
servo2.speed -90
|
58
|
+
servo3.speed -90
|
59
|
+
servo4.speed -90
|
60
|
+
delay_servo 2000 # two full seconds max clockwise
|
61
|
+
servo1.speed 90
|
62
|
+
servo2.speed 90
|
63
|
+
servo3.speed 90
|
64
|
+
servo4.speed 90
|
65
|
+
delay_servo 2000 # two full seconds max counter clockwise
|
66
|
+
|
67
|
+
@test_state = 1 # setup for zero speed test/adjust
|
68
|
+
@cycle_time = millis + 20000
|
69
|
+
servo1.speed 0
|
70
|
+
servo2.speed 0
|
71
|
+
servo3.speed 0
|
72
|
+
servo4.speed 0
|
73
|
+
toggle led # lights off, OK you have 20 seconds to adjust
|
74
|
+
end
|
75
|
+
|
76
|
+
if @cycle_time - millis <= 0
|
77
|
+
@test_state = 2
|
78
|
+
else
|
79
|
+
servo_refresh
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
def delay_servo(t)
|
86
|
+
t.times do
|
87
|
+
delay 1
|
88
|
+
servo_refresh
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class ServoThrottle < ArduinoSketch
|
2
|
+
|
3
|
+
# updated 20080731
|
4
|
+
# replaced external variables with instance style variables
|
5
|
+
|
6
|
+
# potentiometer to control servo
|
7
|
+
# with a bit of hysteresis
|
8
|
+
# use analog pin for sensor
|
9
|
+
# need to format the output of sensor_position and sensor_amount
|
10
|
+
|
11
|
+
@sensor_position = 0
|
12
|
+
@servo_amount = 0
|
13
|
+
|
14
|
+
output_pin 5, :as => :my_lcd, :device => :sf_lcd
|
15
|
+
input_pin 1, :as => :sensor
|
16
|
+
output_pin 2, :as => :my_servo, :device => :servo
|
17
|
+
|
18
|
+
|
19
|
+
def loop
|
20
|
+
servo_refresh
|
21
|
+
#delay 9 # comment out if using servo status, since it will add enough delay
|
22
|
+
@sensor_position = analogRead(sensor)
|
23
|
+
@servo_amount = (add_hysteresis(@sensor_position, 10)*0.36)
|
24
|
+
my_servo.position @servo_amount
|
25
|
+
servo_status
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def servo_status
|
30
|
+
|
31
|
+
my_lcd.setxy 0,0 # line 0, col 0
|
32
|
+
my_lcd.print "Read Send"
|
33
|
+
my_lcd.setxy 0,1 # line 1, col 0
|
34
|
+
my_lcd.print @sensor_position # need method of blanking out previous reading
|
35
|
+
my_lcd.setxy 6,1
|
36
|
+
my_lcd.print @servo_amount
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class SparkfunLcd < ArduinoSketch
|
2
|
+
|
3
|
+
|
4
|
+
input_pin 6, :as => :button_one, :latch => :off
|
5
|
+
input_pin 7, :as => :button_two, :latch => :off
|
6
|
+
input_pin 8, :as => :button_three, :latch => :off
|
7
|
+
output_pin 13, :as => :led
|
8
|
+
|
9
|
+
swser_LCDsf 5, :as => :my_lcd
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
#serial_begin # not necessary when using :device => :sf_lcd or :pa_lcd
|
15
|
+
|
16
|
+
def loop
|
17
|
+
check_buttons
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
# need a bit
|
22
|
+
|
23
|
+
def say_hello
|
24
|
+
my_lcd.setxy 0,0 # line 0, col 0
|
25
|
+
my_lcd.print "All your base "
|
26
|
+
my_lcd.setxy 0,1 # line 1, col 0
|
27
|
+
my_lcd.print "are belong to us"
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
def say_ruby
|
32
|
+
my_lcd.setxy 0,0 # line 0, col 0
|
33
|
+
my_lcd.print " Ruby + Arduino "
|
34
|
+
my_lcd.setxy 0,1 # line 1, col 0
|
35
|
+
my_lcd.print " RAD 0.2.4+ "
|
36
|
+
# un comment to change display startup
|
37
|
+
#myLCD.setcmd 0x7C, 10
|
38
|
+
end
|
39
|
+
|
40
|
+
def check_buttons
|
41
|
+
read_and_toggle button_one, led
|
42
|
+
say_hello if read_input button_two
|
43
|
+
say_ruby if read_input button_three
|
44
|
+
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class SpectraSoftPot < ArduinoSketch
|
2
|
+
|
3
|
+
# demonstrate capability to use soft pot as traditional pot
|
4
|
+
# the last pot reading remains "locked" to the last touch point
|
5
|
+
# similar same behavior as ipod
|
6
|
+
#
|
7
|
+
# this sketch assumes a pa_lcd operating at 19200 and one
|
8
|
+
# spectra symbol softpot connected to analog pin 3
|
9
|
+
#
|
10
|
+
|
11
|
+
output_pin 5, :as => :my_lcd, :device => :pa_lcd, :rate => 19200, :clear_screen => :true
|
12
|
+
input_pin 3, :as => :sensor_one, :device => :spectra
|
13
|
+
|
14
|
+
|
15
|
+
def setup
|
16
|
+
delay 1000
|
17
|
+
my_lcd.setxy 0,0, "spectra symbol"
|
18
|
+
my_lcd.setxy 0,1, "soft pot"
|
19
|
+
delay 5000
|
20
|
+
my_lcd.clearscr
|
21
|
+
end
|
22
|
+
|
23
|
+
def loop
|
24
|
+
my_lcd.setxy 0,1
|
25
|
+
# since lcd's have issues clearing tens and hundreds digits when reading ones,
|
26
|
+
# we use pad_int_to_str, which is a hack to display these cleanly
|
27
|
+
# pad_int_to_str takes two arguments: an integer and the final string length
|
28
|
+
#
|
29
|
+
my_lcd.print pad_int_to_str sensor_one.soft_lock, 3
|
30
|
+
delay 100
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class Twitter < ArduinoSketch
|
2
|
+
|
3
|
+
#include <avr/io.h>
|
4
|
+
#include <string.h>
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
define "TWEETLEN 141"
|
9
|
+
define "HOSTNAME www.twitter.com"
|
10
|
+
|
11
|
+
define 'IPADDR "128.121.146.100"' # twitter.com
|
12
|
+
define "PORT 80" # // HTTP
|
13
|
+
define "HTTPPATH /atduskgreg/" # // the person we want to follow
|
14
|
+
|
15
|
+
|
16
|
+
define "TWEETLEN 141"
|
17
|
+
array "char linebuffer[256]" # // our large buffer for data
|
18
|
+
array "char tweet[TWEETLEN]" # // the tweet
|
19
|
+
@lines = 0
|
20
|
+
|
21
|
+
|
22
|
+
define "XPORT_RXPIN 2"
|
23
|
+
define "XPORT_TXPIN 3"
|
24
|
+
define "XPORT_RESETPIN 4"
|
25
|
+
define "XPORT_DTRPIN 5"
|
26
|
+
define "XPORT_CTSPIN 6"
|
27
|
+
define "XPORT_RTSPIN 7"
|
28
|
+
|
29
|
+
|
30
|
+
@errno = 0
|
31
|
+
@laststatus = 0
|
32
|
+
@currstatus = 0
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# in setup
|
37
|
+
#xport = AF_XPort(XPORT_RX, XPORT_TX, XPORT_RESET, XPORT_DTR, XPORT_RTS, XPORT_CTS)
|
38
|
+
|
39
|
+
|
40
|
+
output_pin 10, :as => :shield, :device => :ethernet
|
41
|
+
|
42
|
+
serial_begin :rate => 57600
|
43
|
+
|
44
|
+
def loop
|
45
|
+
|
46
|
+
# local_connect()
|
47
|
+
# kind of a problem... fixed
|
48
|
+
get_tweet
|
49
|
+
fetchtweet
|
50
|
+
delay 30000
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
end
|