-
-
Save Epictetus/1810753 to your computer and use it in GitHub Desktop.
Arduino+Ruby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int incomingByte = 0; | |
int ledPin = 13; | |
void setup() { | |
Serial.begin(9600); | |
pinMode(ledPin, OUTPUT); | |
} | |
void loop() { | |
if (Serial.available() > 0) { | |
incomingByte = Serial.read(); | |
for(int i= 0; i< (incomingByte - 48); i++ ) | |
{ | |
digitalWrite(ledPin, HIGH); | |
delay(500); | |
digitalWrite(ledPin, LOW); | |
delay(500); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'serialport' //gem install serialport | |
port = "/dev/cu.usbmodemfd121" | |
sp = SerialPort.new(port, 9600, 8, 1, SerialPort::NONE) | |
while true | |
line = gets.chomp | |
sp.putc line | |
end | |
sp.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment