Skip to content

Instantly share code, notes, and snippets.

View julioterra's full-sized avatar

Julio Terra julioterra

View GitHub Profile
@julioterra
julioterra / tic_tac_toe.ino
Last active December 15, 2015 12:29
This is the code for a tic tac toe project that I did a few years back using an arduino. It requires 11 leds, 1 potentiometer and 1 button.
// setting a variable to pin number 13
int tictacPins [] = {2,3,4,5,6,7,8,9,10,11}; // holds pin location of each LED (including the active user one at 0)
int userPin = 0; // holds the location on the array where the active user is displayed
int winnerPin = 13; // holds number of pin attached to winner notification led
int buttonPin = 12; // holds number of pin for button input
int potPin = 0; // holds number of pin for the potentionmeter
int potRead = 0; // holds the pot value
int potRange = 0; // holds the value of the pot range to go from one LED to the next
int activeUser = 1; // holds the active user (1 or 0)
@julioterra
julioterra / gist:4743881
Created February 9, 2013 04:48
Command syntax for uploading pre-compiled firmware to and Arduino Mega
path_to_file/avrdude -Cpath_to_file/avrdude.conf -v \
-patmega2560 -carduino -D -b 115200 -cstk500v2 \
-P/dev/tty.port_name -Uflash:w:path_to_file/file_name.hex:i
@julioterra
julioterra / gist:4743875
Created February 9, 2013 04:46
Example command for uploading pre-compiled firmware hex file to an Arduino Mega.
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude \
-C/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf \
-v -patmega2560 -carduino -D -b 115200 -cstk500v2 -P/dev/tty.usbmodem411 \
-Uflash:w:/Developer/_LAB_Projects/prototypes_experiments/Polargraph/arduino_code/polargraph-read-only/embedded/branch/polargraph_server_polarshield/polargraph_server_polarshield.cpp.hex:i
@julioterra
julioterra / forest_input_arduino.pde
Created May 6, 2012 01:33
Here is the input file that I tried to connect to ECS.
import processing.serial.*;
import com.rockwellgroup.lab.ecsp5.*; // import the processingECS library
ECSConnection pECS; // create a new object - see docs at http://www.ecsTBD.com for more info
String ECS_role_name = "forest_input_arduino";
// set the serial port name here, otherwise app will attempt to connect to first serial port
String serial_port_name = "411";
boolean serial_connected = false;
Serial arduino;
@julioterra
julioterra / forest_output_arduino.pde
Created May 6, 2012 01:32
Output file that I have connected via ECS
import processing.serial.*;
import com.rockwellgroup.lab.ecsp5.*; // import the processingECS library
ECSConnection pECS; // create a new object - see docs at http://www.ecsTBD.com for more info
String ECS_role_name = "forest_output_arduino";
boolean ecs_connected = false;
// Create serial object and set the name of the Serial port we want to connect to
Serial arduino;
String serial_port_name = "641";
@julioterra
julioterra / gist:2506237
Created April 27, 2012 05:42 — forked from adenine/gist:2503536
Quick Maker Sketch w/ Arduino Serial Connection
import processing.serial.*;
import com.rockwellgroup.lab.processingecs.*; // import the processingECS library
ProcessingECS pECS; // create a new object - see docs at http://www.ecsTBD.com for more info
/**
* Maker Faire building sketch
* This controls a set of 4 window outputs and reads from 4 inputs
*/
@julioterra
julioterra / gist:1273193
Created October 9, 2011 02:13
IO output methods: puts and print
array = ["testing", "puts", "and", "print"]
puts "(1) putting the array: ", array
print "(2) printing the array: ", array
@julioterra
julioterra / gist:1273192
Created October 9, 2011 02:12
IO output methods: print and printf
num = 31
print "dec: ", num, " hex: ", num.to_s(16), " bin: ", num.to_s(2), "\n"
printf "dec: %d hex: %x bin: %08b\n", num, num, num
@julioterra
julioterra / gist:1273191
Created October 9, 2011 02:10
File navigation
file_obj.rewind
file_obj.pos = 10
file_obj.seek(30, IO::SEEK_CUR)
@julioterra
julioterra / gist:1272490
Created October 8, 2011 16:17
Creating a file object
file_obj = File.new(filename [, mode string or options hash])
file_obj = File.open(filename [, mode string or options hash])
File.open(filename [, mode string or options hash]) {|file_obj| block}