|
|
Line 79: |
Line 79: |
| Implemented with Arduino, Processing, a radio switch, a radio transmitter and ControlMyNikon. | | Implemented with Arduino, Processing, a radio switch, a radio transmitter and ControlMyNikon. |
|
| |
|
| Processing Code: | | [[File:vegancip_send.txt|Processing Code]] |
| <quote>
| | [[File:vegancip_receive.txt|Arduino Code]] |
| import processing.serial.*;
| |
| int colour = 0;
| |
| boolean sign = false;
| |
| Serial port;
| |
| | |
| void setup(){
| |
| //println(Serial.list());
| |
| String portName = Serial.list()[0];
| |
| port = new Serial(this, portName, 57600);
| |
| }
| |
| | |
| | |
| void draw()
| |
| {
| |
| fill(colour);
| |
| rect(25,25,50,50);
| |
| }
| |
| /*if (hour() < 12) {
| |
| port.write('H');
| |
| delay(3000);
| |
| port.write('L');
| |
| delay(297000);
| |
| }
| |
| if (hour() >= 12) {
| |
| port.write('H');
| |
| delay(1000);
| |
| }*/
| |
| | |
| | |
| | |
| //CONTROL BY MOUSE
| |
| | |
| void mousePressed() {
| |
| colour = 200;
| |
| port.write('H');
| |
| | |
| }
| |
| | |
| void mouseReleased() {
| |
| colour = 70;
| |
| port.write('L');
| |
| | |
| }
| |
| </quote>
| |
| | |
| Adruino Code:
| |
| <quote>
| |
| #include <RCSwitch.h>
| |
| | |
| int incomingByte;
| |
| //int ledPin = 13;
| |
| RCSwitch mySwitch = RCSwitch();
| |
| | |
| void setup()
| |
| {
| |
| Serial.begin(57600);
| |
| mySwitch.enableTransmit(10);
| |
| }
| |
| | |
| void loop()
| |
| {
| |
| if (Serial.available() > 0)
| |
| {
| |
| incomingByte = Serial.read();
| |
| if (incomingByte == 'H')
| |
| {
| |
| Serial.println("on");
| |
| //digitalWrite(ledPin, HIGH);
| |
| mySwitch.switchOn("01110", 2);
| |
| }
| |
| if (incomingByte == 'L')
| |
| {
| |
| //digitalWrite(ledPin, LOW);
| |
| Serial.println("off");
| |
| mySwitch.switchOff("01110", 2);
| |
| }
| |
| }
| |
| }
| |
| </quote>
| |
|
| |
|
|
| |
|