Coder Social home page Coder Social logo

igallina / arduino Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashnuke/arduino

0.0 2.0 0.0 120 KB

A ruby library to talk to Arduino without having to burn programs repeatedly to the board

Home Page: https://github.com/HashNuke/arduino/

License: MIT License

Java 31.76% Ruby 68.24%

arduino's Introduction

Arduino ruby gem

This gem is a prototyping API for Arduino in Ruby. Helps prototype Arduino programs quickly from the computer, without the need to burn to the board frequently.

Setup:

  1. Install the gem: gem install arduino
  2. Load arduino.pde onto your Arduino dev board (just once and for all).
  3. Import the arduino gem: require "arduino"

Methods

Initializing:

#Arduino.new(port, baudrate)
board = Arduino.new("/dev/ttyUSB1")

Port is something like "/dev/ttyUSB0" on linux and COMx (COM1/COM2) on windows. Baudrate is optional. It is 115200 by default.

Setting output pins

The output pins must be set explicitly.

#Arduino.output(list_of_output_pins)
board.output(10,11,13)

Digital I/O

  1. Arduino.setHigh(pin)
  2. Arduino.setLow(pin)
  3. Arduino.getState(pin) - returns true if pin state is high, else it returns false

Analog I/O

  1. Arduino.analogRead(pin) - returns the analog value
  2. Arduino.analogRead(pin, value) - sets the analog value

Misc

1.) Arduino.turnOff - sets all the pins to low state

2.) Arduino.close - closes serial connection. Using this makes sure that you won't have to disconnect & reconnect the Arduino again to recover the serial port.

Usage example

	# This is the blink program.

	require "arduino"

	#specify the port Baudrate is optional and set to 115200 by default
	board = Arduino.new("/dev/ttyUSB1")

	#declare output pins
	board.output(13)

	#perform operations
	10.times do
		board.setHigh(13)
		sleep(1)
		board.setLow(13)
		sleep(1)
	end

Developed for the love of creating stuff by

© 2010 Akash Manohar [email protected] under the MIT License

Credits

Thanks to the following people:

  • @unsymbol - for fixing the Ubuntu reset problem

arduino's People

Contributors

hashnuke avatar igallina avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.