oh blog

Icon

i rant cherish and archive my memories here

[final] code update

Got the basic communication logic working.

Steps left:

1. get the initial connection solid -

BT auto-connect works only when the boards is started within the range.

. solution -

1) set TV to initiate the communication (send T first instead of having P sent first)

2) try backup AT commands such as ATDM

2. Disconnect logic is off for now

.solution -

1) should have TV arduino write the AT commands to pedometer to get it working?!?!

2) or in processing

3) but when/where? -> when signal pin is HIGH && connected, send indicator to tell TV to write commands on pedometer

—————————–

*codes*

arduino code for pedometer:

pedometer_BT5

arduino code for TV:

tv_BT5

processing code for the communication between two arduinos:

processing_BT5


Filed under: Networked Objects

[final] logic

logic

processing code:

———————————-

import processing.serial.*;
//Serial.java

//BT1 = pedometer`
//BT2 = computer/TV

Serial BTPort;      //to pedometer
Serial tvPort;      //to TV

char inByte_p;
char inByte_t;
char counter;
int val = 0;
char inString[];
int stringPos = 0;

//int tv = 0;
//int pedo = 0;

void setup() {
println(Serial.list());
BTPort = new Serial(this, “COM18″, 9600);
tvPort = new Serial(this, “COM7″, 9600);
//BTPort.bufferUntil(‘\r’);
//tvPort.bufferUntil(‘\r’);

}

void draw() {
}

void serialEvent(Serial BTPort) {
inByte_p = char(BTPort.read());
inByte_t = char(tvPort.read());
//inByte_t = tvPort.readChar();

//tvPort.write(inByte_p);
//BTPort.write(inByte_t);

if (inByte_p == ‘P’) {
tvPort.write(‘P’);
println(“pass1″);
}
if (inByte_t == ‘T’) {
BTPort.write(‘T’);
println(“pass2″);
}
if (inByte_t == ‘R’) {
BTPort.write(‘R’);
println(“pass3″);
}
if ((inByte_p >= ‘0′) && (inByte_p <= ‘9′)){
/*for (int i = 0; i <=4; i ++){
inString[i] = inByte_p;
// int i = Integer.parseInt(inString);
tvPort.write(inString[i]);
print (inString[i]);
}*/
tvPort.write(inByte_p);
println (inByte_p);
println(“pass4″);

}
if (inByte_t == ‘G’) {
BTPort.write(‘G’);
println(“pass5″);
}
/*
if (inByte_p == ‘S’) {
// convert the string to a number:
int val = atoi(inString);
// put zeroes in the array
for (int c = 0; c < stringPos; c++) {
inString[c] = 0;
}
stringPos = 0;
}*/

println(“pedo:” +inByte_p);
println(“tv:”+inByte_t);
//println(“pedo:”+BTPort.read());
//println(“tv:”+tvPort.read());

}
———————–

Filed under: Networked Objects

[final] Arduino code for TV/111806

/*NOTE:

similar as pedometer. works with manual-type-ins. not sure with ‘\r’ after Serial.print*/

/* TV power control with BT communication
jane oh
11.18.06
*/
#define tvPin 2
#define powerPin 3
#define ledPin 13
#define inPin 12
#define break 50

int inByte = -1;
char inString[4];
int stringPos = 0;
int counter = 0;
long power = 0;
int button = 0;
int currentState = 0;
int preState = 0;

void setup()
{
pinMode(inPin, INPUT);
pinMode(powerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
pinMode(tvPin, OUTPUT);     // sets the digital pin as output
Serial.begin(9600);

blink(3);   //blinkie
}

void loop(){
//send data only when you receive data
if (Serial.available() > 0) {
digitalWrite(ledPin, HIGH);
inByte = Serial.read();

//when receive ‘P’ send ‘T’ as response
if (inByte == ‘P’){
//blink(2);
Serial.print(‘T’); //”T” needed?!?!
delay(break);
delay(break);
//ask for counter value
Serial.print(‘C’);
delay(break);
}
//when receive counter value, store it and send ‘G’ as good
if ((inByte >= ‘0′) && (inByte <= ‘9′)){
//blink(2);
inString[stringPos] = inByte;
stringPos++;
//give ‘G’ as in good transfer of data
Serial.print(‘G’);
delay(break);
}
if (inByte == ‘S’){
blink(2);
counter = atoi(inString);
//Serial.print(counter);
power = counter * 1000;
//Serial.print(power);
// put zeroes in the array
for (int c = 0; c < stringPos; c++) {
inString[c] = 0;
}
// reset the string pointer:
stringPos = 0;
}
}

//turn on TV when press the button
button = digitalRead(inPin);
if (button == HIGH){
currentState = 1;
}
else {
currentState = 0;
}
if (currentState != preState){
if (currentState == 1){
powerControl();
}
}
preState = currentState;
}

//turn on TV for the amount of counter time
void powerControl(){
for (long i=0; i <= power; i++){
digitalWrite(tvPin, HIGH);
digitalWrite(powerPin, HIGH);
//Serial.print(i);
if (i == power){
digitalWrite(tvPin, LOW);
digitalWrite(powerPin, LOW);
}
}
counter = 0;
power = 0;
}

// Blink an LED:
void blink(int howManyTimes) {
for (int i=0; i< howManyTimes; i++) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
}
}

Filed under: Networked Objects, pcomp

[final] Arduino code for Pedometer/111806

/*NOTE:

it kinda works logically with serial-USB connection and with mannually-typed-in commands. but had some troubles with BT communication- virtual serial port error – and Signal Strength detection – timing, swtiching between dataMode and commandMode with \r, uncertainty with Strength indicator value and all.. -  */

/* pedometer counter with BT communication
jane oh
11.18.06
**********reminder**************
miniarduino: atmega168
serial baudrate: 9600
********************************
*/
#define ledPin 13  // choose the pin for the LED
#define statPin 12
#define inPin 9    // choose the input pin (for a pushbutton)
#define break 500   // variable for the break after serial send

int val = 0;     // variable for reading the pin status
int stat = 0;    // variable for BT status
int counter = 0;
int currentState = 0;
int preState = 0;

int inByte = -1;
boolean far = false;

void setup() {
pinMode(ledPin, OUTPUT);  // declare LED as output
pinMode(statPin, OUTPUT);
pinMode(inPin, INPUT);    // declare pushbutton as input
Serial.begin(9600);

blink(3);  //blinkie

digitalWrite(inPin, LOW);
}

void loop(){
inByte = Serial.read();
if (inByte == ‘T’){ //need to type ‘T’ not T. weird..
stat = 1;
}

if (far){
stat = 0;
}

//when connected, do BT communication
if (stat == 1){
digitalWrite(statPin, HIGH);
BTtalk();
}
//when disconnected, send signal and start counting
if (stat == 0) {
digitalWrite(statPin, LOW);
//Serial.print(‘P’);
//delay(break);
stepCount();
}
}

void stepCount(){
val = digitalRead(inPin);  // read input value
if (val == HIGH) {         // check if the input is HIGH
digitalWrite(ledPin, HIGH);  // turn LED ON
currentState = 1;
}
else {
digitalWrite(ledPin, LOW);  // turn LED off
currentState = 0;
}

if ((currentState != preState) && (stat == 0)){
if (currentState == 1){
counter = counter + 1;
//Serial.print(counter, DEC);
Serial.print(‘P’);
delay(400); //500 little lagging
}
}
preState = currentState;
}

void BTtalk(){
//when connected to TV, send counter value
if (inByte == ‘C’){
Serial.print(counter, DEC);
delay(break);
//blink(2);
Serial.print(‘S’);
}

//when sent counter value, set the value to 0
if (inByte == ‘G’){
counter = 0;
//blink(2);
}
//detect distance
checkSSI();
}

//get Signal Strength info and detect distance
void checkSSI(){
Serial.print(“+++”); //go into commandMode
// wait for the radio to respond with “OK\r”
char thisByte = 0;
while (thisByte != ‘\r’) {
if (Serial.available() > 0) {
thisByte = Serial.read();
}
}
Serial.print(“ATRSSI\r”); //get the signal strength indicator
if (inByte <= ‘-20′){
far = true;
}
else {
far = false;
}
Serial.print(“ATMD\r”); //go back to datamode
}

// Blink an LED:
void blink(int howManyTimes) {
for (int i=0; i< howManyTimes; i++) {
digitalWrite(statPin, HIGH);
delay(200);
digitalWrite(statPin, LOW);
delay(200);
}
}

Filed under: Networked Objects, pcomp

Spoiled Gumball Machine code

spoiledgumballmachine.com

documentation

http://spoiledgumball.blogspot.com/ 

‘****************************************************************
‘* Name : gumball121205.BAS *
‘* Author : gumball group *
‘* Notice : Copyright (c) 2004 [select VIEW...EDITOR OPTIONS] *
‘* : All Rights Reserved *
‘* Date : 12/12/2005 *
‘* Version : 1.0 *
‘* Notes : *
‘* : *
‘****************************************************************
DEFINE OSC 4
start:
INCLUDE “modedefs.bas”
‘ Define ADCIN parameters
‘ Set number of bits in result
DEFINE ADC_BITS 10
‘ Set clock source (3=rc)
DEFINE ADC_CLOCK 3
‘ Set sampling time in microseconds
DEFINE ADC_SAMPLEUS 10
‘ Set PORTA to all input
TRISA = %11111111
‘ Set up ADCON1 analog and right justify the result
adcon1 = %10000010

pause 500

‘define inputs and outputs
‘test
output PORTD.0
‘LEDs for testing
OUTPUT PORTD.1
‘play
OUTPUT PORTD.2
’stop
OUTPUT PORTD.3
‘FF
OUTPUT PORTC.4
‘RW
OUTPUT PORTC.5
’solenoids
OUTPUT PORTC.1
OUTPUT PORTC.2
OUTPUT PORTC.3
‘LEDs
OUTPUT PORTB.0

‘PIEZO from other board
INPUT PORTB.6
‘beginning switch
Input PORTB.7

’set all the input ports low
LOW PORTD.0
LOW PORTD.1
LOW PORTD.2
LOW PORTD.3
LOW PORTC.4
LOW PORTC.5
LOW PORTB.5
LOW PORTB.6
LOW PORTB.7
LOW PORTC.1
LOW PORTC.2
LOW PORTC.3
LOW PORTB.0

pause 500

‘define adc vars
adcVar1 VAR WORD  ‘PIEZO(move)
adcVar2 VAR WORD  ‘MIC(sound)
adcVar3 VAR WORD  ‘FSR(touch)

’set vars
theStage var byte
trackPlayed VAR BYTE
jumpLevel var WORD
whisperLevel var WORD
touchLevel var WORD
startup var byte
counter VAR WORD
countEval var byte
petCounter VAR BYTE

’set your acceptable params here
jumpLevel = 500
whisperLevel = 300
touchLevel  = 600
counter = 0
petCounter = 0

’set your booleans here
theStage = 0
trackPlayed =0
startup = 1
countEval =0

‘test out the start with LED blinking
HIGH PORTD.1
pause 200
LOW PORTD.1
pAUSE 200
HIGH PORTD.1
pause 200
LOW PORTD.1
pAUSE 200
HIGH PORTD.1
pause 200
LOW PORTD.1
pAUSE 200

”test out the start with Solenoid moving
‘HIGH PORTB.5
‘pause 500
‘LOW PORTB.5
‘pAUSE 500
‘HIGH PORTB.5
‘pause 500
‘LOW PORTB.5
‘pAUSE 500

‘prep the cd
IF startup = 1 Then
’start the CD player
HIGH PORTD.2
pause 500
low PORTD.2
pause 7000 ‘heating up time
‘pause the CD player
HIGH PORTD.2
pause 500
low PORTD.2
startup = 0
EndIf

main:
‘initiating cycle
if theStage = 0 then
‘if the user has turned the handle start the program
if PORTB.7 = 1 then
‘play the first track and pause cd player(#1)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
Pause 6500 ‘time of intro song
‘light up the LEDs
HIGH PORTB.0
PAUSE 7000
LOW PORTB.0

‘pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250

theStage = 1
endIF
endIF

‘jump
if theStage = 1 then
‘make sure serial communicator has Baudrate of 9600!
‘trigger this with a boolean
if trackPlayed = 0 then
‘play the first track and pause cd player(#2)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
Pause 5500 ‘time of task one track
‘light up the LEDs
HIGH PORTB.0
PAUSE 6000
LOW PORTB.0

‘pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250

trackPlayed = 1
endIF

‘we need to give some time test ppl’s jumping;
‘what if we have blank sound after the voice in a track
‘to give time to test instead of pausing??

‘make sure serial communicator has Baudrate of 9600!
test1
ADCIN 1, adcVar1
serout2 portc.6, 16468, [DEC adcVar1,10,13]

counter = counter + 1
‘light up the LEDs

IF adcVar1 >= jumplevel then
‘forward to the proper track
HIGH PORTC.4
PAUSE 500
LOW PORTC.4
PAUSE 500
‘play the proper track(#4)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
pause 2500   ‘time of third track
‘light up the LEDs
HIGH PORTB.0
PAUSE 3000
LOW PORTB.0

‘Pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
‘open first solenoid
HIGH PORTC.1
PAUSE 2000
LOW PORTC.1
PAUSE 250

theStage = 2
trackPlayed = 0
countEval=1
ENDIF
‘not enough
IF counter = 1000 and countEval = 0 THEN
‘play the proper track(#3)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
pause 5000   ‘time of third track
‘light up the LEDs
HIGH PORTB.0
PAUSE 5500
LOW PORTB.0

‘Pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
‘rewind the track
HIGH PORTC.5
PAUSE 500
LOW PORTC.5
PAUSE 500
counter = 0
GOTO test1
endIF
endIF

‘touch
if theStage = 2 then
‘trigger this with a boolean
if trackPlayed = 0 then
countEval = 0
counter = 0
‘play the second challenge track and pause cd player(#5)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
Pause 6500 ‘time of fourth track
‘light up the LEDs
HIGH PORTB.0
PAUSE 7000
LOW PORTB.0

‘pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
trackPlayed = 1
endIF

test2
ADCIN 2, adcVar2
serout2 portc.6, 16468, [ DEC adcVar2,10,13]

‘  petCounter = petCounter + 1
counter = counter + 1

if adcVar2 >= touchLevel then
petCounter = petCounter + 1
if  petCounter = 200 then
‘forward to the proper track
HIGH PORTC.4
PAUSE 500
LOW PORTC.4
PAUSE 500
‘play the proper track(#7)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
pause 4500  ‘time of the track
‘light up the LEDs
HIGH PORTB.0
PAUSE 5000
LOW PORTB.0

‘Pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
‘open second solenoid
HIGH PORTC.2
PAUSE 2000
LOW PORTC.2
PAUSE 250

theStage = 3
trackPlayed = 0
countEval = 1
endif
endIF
‘not enough
IF counter = 1000 and countEval = 0 THEN
‘play the proper track(#6)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
pause 8000   ‘time of the track
‘light up the LEDs
HIGH PORTB.0
PAUSE 8500
LOW PORTB.0

‘Pause CD player
High PORTD.2
PAUSE 250
LOW PORTD.2
PAUSE 250
‘rewind the track
HIGH PORTC.5
PAUSE 500
LOW PORTC.5
PAUSE 500

counter=0
GOTO test2
endIF
endIF

‘whisper
if theStage = 3 then
‘trigger this with a boolean
if trackPlayed = 0 then
countEval = 0
counter = 0
‘play the third challenge track and pause cd player(#8)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
Pause 8500 ‘time of the track
‘light up the LEDs
HIGH PORTB.0
PAUSE 9000
LOW PORTB.0

‘pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
trackPlayed = 1
endIF

test3
ADCIN 3, adcVar3
serout2 portc.6, 16468, [ DEC adcVar3,10,13]

counter = counter + 1

if adcVar3 >= whisperLevel then
‘forward to the proper track
HIGH PORTC.4
PAUSE 500
LOW PORTC.4
PAUSE 500
‘play the proper track(#10)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
pause 4500 ‘time of the track
‘light up the LEDs
HIGH PORTB.0
PAUSE 5000
LOW PORTB.0

‘Pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250

theStage = 4
trackPlayed = 0
countEval = 1
endIF
‘not enough
IF counter = 1000 and countEval = 0 THEN
‘play the proper track(#9)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
pause 4500   ‘time of the track
‘light up the LEDs
HIGH PORTB.0
PAUSE 5000
LOW PORTB.0

‘Pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
‘rewind the track
HIGH PORTC.5
PAUSE 500
LOW PORTC.5
PAUSE 500
counter=0
GOTO test3

endIF
endif

‘celebration of achievement
if theStage = 4 then
‘trigger this with a boolean
if trackPlayed = 0 then
‘play the congratulations and reset cd player(#11)
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
Pause 8000  ‘time of final:good-bye track
‘light up the LEDs
HIGH PORTB.0
PAUSE 8500
LOW PORTB.0

‘pause CD player
High PORTD.2
PAUSE 500
LOW PORTD.2
PAUSE 250
‘       ‘open third solenoid
HIGH PORTC.3
PAUSE 2000
LOW PORTC.3
PAUSE 250

trackPlayed = 1
endIF
theStage = 5
trackPlayed = 0
endif

IF theStage = 5 THEN
‘reset the CD player (forward to the first track and wait)
HIGH PORTC.4
PAUSE 500
LOW PORTC.4
PAUSE 500
theStage = 0
LOW PORTB.7

ENDIF

goto main

Filed under: pcomp

[final] BT resolder and Perf board

Resoldered the headers on BlueSmirf in order to make it seat flat onto the board.

bluetooth resloder

and made a perfboard with female headers for Mini Arduino and BlueSmirf.

Now it’s nice and flat and small!

* To save up space, terminals for power input and pedometer connection go under arduino and bluesmirf.

perfboard

Filed under: Networked Objects

[Recurring Art] Walking Potato

Digilog: Digital technology + Analog sentiment

subversive art?

.

Marcel Duchamp:

google images

Wim Delvoye:

http://www.cloaca.be/machines.htm

google images

Filed under: Networked Objects, pcomp

source

Filed under: pcomp

[final] questions

1. why bluetooth?

- why not simple serial connector on TV that reads in the pedometer value:

since you will be at home with your pedometer and TV together when you want to watch TV anyways?

.

2. add distance detection

- since my idea is not to create an exercising force but to make people to go out and see more, counter should only work when people are walking away from home

- to achieve it,

activate counter only when bluetooth loses its pairing

-> but is it possible?!

Filed under: Networked Objects

[thesis] ideas & feedbacks

idea:

bring digital technology to enrich analogic life.

plan:

- netObject final: steps you take control the power of TV

- more: the time you spend ‘talking’ determines the internet access

- cellphone

- touch/contact with people

feedbacks:

- compensation system in question: does it really give value for analog life?

- analog is forever: human senses analogic value after all

- tactic/physical experience matters: LP vs mp3 -> it’s all about whole experience

- motivation matter: why would people go through the system for the permit when they can get it without any trouble?

thoughts:

- think about what it is that warms people’s ‘heart’

- what are we missing out really due to the ‘evil’ technology?: physical contact. sincereness. nature. time for appreciation = 여유. peace of mind. beauty of solitute.

- or if technology actually improves your analogic experience, how so?

- is technology really evil??

Filed under: Thesis: Oh, Chandelier

Twitter updates

del.icio.us