oh blog

Icon

i rant cherish and archive my memories here

Xport: hello internet

connections:

ethernet cable for xport(128.122.151.201)

serial cable
1. serial terminal

: reset button returns D as disconnect

: reset button and holding down X returns configuration mode
2. telnet

: open IPaddress port#
then, terminal and telnet talks to each other.

Xport(USB-serial) to internet?!??

Filed under: Networked Objects

[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

[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

[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

TV control with transistor TIP120

 got a tv (COBY B/W model from JnR) and got its power controlled with TIP120 transistor.

tv

next step will be set up Bluetooth so that pedometer and TV can communicate to each other.

——————-

<code>

——————–

/* TV simple power control
*/

int tvPin = 2;
int ledPin = 13;

void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(tvPin, OUTPUT); // sets the digital pin as output

digitalWrite(ledPin, HIGH); // sets the LED on
delay(200); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(200); // waits for a second
digitalWrite(ledPin, HIGH); // sets the LED on
delay(200); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(200); // waits for a second
digitalWrite(ledPin, HIGH); // sets the LED on
delay(200); // waits for a second
digitalWrite(ledPin, LOW); // sets the LED off
delay(200); // waits for a second
}

void loop()
{
digitalWrite(tvPin, HIGH);
digitalWrite(ledPin, HIGH); // sets the LED on
//delay(5000); // waits for a second
//digitalWrite(tvPin, LOW);
//digitalWrite(ledPin, LOW); // sets the LED off
//delay(5000); // waits for a second
}

Filed under: Networked Objects, pcomp

Pedometer with Mini Arduino

Tested a hacked pedometer with a mini arduino.

Two reminders:

set the chip to ATmega168 when program.

and set serial boudrate to 19200 for the convenience of Bluetooth?!

pedometer with mini arduino

<< click the image to enlarge >>

code

—————————

/* pedometer simple counter
jane oh
10.30.06
**********reminder**************
miniarduino: atmega168
serial baudrate: 19200
********************************
*/

int ledPin = 13; // choose the pin for the LED
int inPin = 9; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status
int counter = 0;
int currentState = 0;
int preState = 0;
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input
Serial.begin(19200);

digitalWrite(ledPin, HIGH); //blinkie
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);

digitalWrite(inPin, LOW);
}

void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button pushed)
digitalWrite(ledPin, HIGH); // turn LED ON
currentState = 1;
}
else {
digitalWrite(ledPin, LOW); // turn LED off
currentState = 0;
}
if (currentState != preState){
if (currentState == 1){
counter = counter + 1;
Serial.print(counter, DEC);;
delay(500);
}
}
preState = currentState;
}

Filed under: Networked Objects, pcomp

Twitter updates

del.icio.us