Sunday, May 1, 2016

Art On The Rise - Parts

Parts used:


Apple iPhone Cardboard App

Android Cardboard App

Videos can be found here and viewed on Google Cardboard











Code for Arduino
#include <Servo.h>

Servo myservo;  // create servo object to control a servo

// int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
char ser;

void setup() {
  Serial.begin(9600);
  
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  
  if (Serial.available() > 0) {
    ser = Serial.read();
  }
  if (ser == '4'){
    myservo.write(10);
  }
  if (ser == '3'){
    myservo.write(30);
  }
  if (ser == '2'){
    myservo.write(60);
  }
  if (ser == '1'){
    myservo.write(75);
  }
  if (ser == 's'){
    myservo.write(150);
  }
  // val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
       // scale it to use it with the servo (value between 0 and 180)
  //myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}

--------------- End code for Arduino -----------------------------

--------------- Begin Python code for Raspberry Pi ----------------

import serial
print("press '4' to go Fast")
print("press '3' to go Medium Fast")
print("press '2' to go Medium Slow")
print("press '1' to go Slow")
print("press 's' to Stop") print("press 'q' to quit") print("") print("")
ser = serial.Serial('/dev/ttyACM0', 9600)
while 1:
        var = raw_input()

        if var  == '4':
                print("Fast")
                ser.write('4')
                print("")
        if var  == '3':
                print("Medium Fast")
                ser.write('3')
                print("")
        if var  == '2':
                print("Medium Slow")
                ser.write('2')
                print("")
        if var  == '1':
                print("SLOW")
                ser.write('1')
                print("")
elif var == 's': print("Stop") ser.write('c') print("") elif var == 'q': print("quitting ......") quit()




Friday, April 29, 2016

ArtOnTheRise2016-SAS

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

// int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin
char ser;

void setup() {
  Serial.begin(9600);
  
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  
  if (Serial.available() > 0) {
    ser = Serial.read();
  }
  if (ser == '4'){
    myservo.write(10);
  }
  if (ser == '3'){
    myservo.write(30);
  }
  if (ser == '2'){
    myservo.write(60);
  }
  if (ser == '1'){
    myservo.write(75);
  }
  if (ser == 's'){
    myservo.write(150);
  }
  // val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
       // scale it to use it with the servo (value between 0 and 180)
  //myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}
###########################

Raspberry Pi:

import serial
print("press 'f' to go Fast")
print("press 'm' to go Medium speed")
print("press 's' to Stop")
print("press 'q' to quit")
print("")
print("")
ser = serial.Serial('/dev/ttyACM0', 9600)
while 1:
        var = raw_input()

        if var  == 'f':
                print("Fast")
                ser.write('a')
                print("")
        elif var == 'm':
                print("Medium")
                ser.write('b')
                print("")

        elif var == 's':
                print("Stop")
                ser.write('c')
                print("")
        elif var == 'q':
                print("quitting ......")
                quit()