User:Birgit bachler/BBB: Difference between revisions
No edit summary |
No edit summary |
||
Line 21: | Line 21: | ||
* http://www.troglodisme.com/?p=42 | * http://www.troglodisme.com/?p=42 | ||
* http://brohogan.blogspot.com/2009/12/telephone-interface.html | * http://brohogan.blogspot.com/2009/12/telephone-interface.html | ||
== code dump == | |||
<source lang="javascript"> | |||
#include <avr/io.h> | |||
#include <avr/interrupt.h> | |||
#define gabelPin 4 | |||
#define klingelEn 7 | |||
#define klingelA 5 | |||
#define klingelB 6 | |||
#define klingelPeriod 2500 //1250 | |||
void setup(void){ | |||
pinMode(gabelPin, INPUT); | |||
digitalWrite(gabelPin, HIGH); | |||
pinMode(klingelEn, OUTPUT); | |||
pinMode(klingelA, OUTPUT); | |||
pinMode(klingelB, OUTPUT); | |||
sei(); | |||
TCCR1B = (_BV(CS12)); //timer at Fcpu/256 | |||
Serial.begin(115200); | |||
} | |||
void scheduleTimerInterrupt(void){ | |||
OCR1A = (unsigned int)TCNT1 + (unsigned int)klingelPeriod; | |||
} | |||
void startKlingel(void){ | |||
scheduleTimerInterrupt(); | |||
TIFR1 |= _BV(OCF1A); | |||
TIMSK1 |= _BV(OCIE1A); | |||
digitalWrite(klingelEn, HIGH); | |||
digitalWrite(klingelA, HIGH); | |||
digitalWrite(klingelB, LOW); | |||
} | |||
void stopKlingel(void){ | |||
TIMSK1 &= ~_BV(OCIE1A); | |||
digitalWrite(klingelEn, LOW); | |||
} | |||
ISR(TIMER1_COMPA_vect){ | |||
PORTD ^= (_BV(5) | _BV(6)); | |||
scheduleTimerInterrupt(); | |||
} | |||
int gabel = 0; | |||
void loop(void){ | |||
int g; | |||
if (Serial.available()){ | |||
switch (Serial.read()){ | |||
case 75: | |||
startKlingel(); | |||
break; | |||
case 107: | |||
stopKlingel(); | |||
break; | |||
} | |||
} | |||
g = digitalRead(gabelPin); | |||
if(g != gabel){ | |||
gabel = g; | |||
if(g){ | |||
Serial.write("g\n"); | |||
} | |||
else { | |||
Serial.write("G\n"); | |||
} | |||
} | |||
} | |||
</source> |
Revision as of 14:22, 14 December 2010
For this thematic project I will make use of the telephone as a dying medium for networking,
and belhuizen are some last public resorts for these machines.
We are very much used to actively using the Internet by visiting websites rather than them visiting us.
Now the Internet is calling you, in the belhuis.
Scraping all this information you want or do not want to find
(sources yahoo answers, craigslist, facebook, brandmonitor etc etc)
and letting this information find you.
Example1: "Ring ring"... "Its a shame you don't know what your worth! You've let pathetic guys ruin you! \nYour better than that! \nIs your BEAUTY, your curse!?"
Example2: "Ring ring".... "Just to be clear, I'm not really looking for a bodyguard (that's a lyric from the song haha!) just a friend named Betty."
Howto
- Data-scraping: python with feedparser etc (facebook, craigslist...)
- Mastercontrolprogram.py (state-machine) + PySerial + Arduino >> Phone
- Text-to-Speech: festival, text2wave on commandline with the "American female"
- Phone: Mod-copper-phone with 2 inputs (1 audio, 1 ring) and 1 output (fork)
* http://www.troglodisme.com/?p=42 * http://brohogan.blogspot.com/2009/12/telephone-interface.html
code dump
#include <avr/io.h>
#include <avr/interrupt.h>
#define gabelPin 4
#define klingelEn 7
#define klingelA 5
#define klingelB 6
#define klingelPeriod 2500 //1250
void setup(void){
pinMode(gabelPin, INPUT);
digitalWrite(gabelPin, HIGH);
pinMode(klingelEn, OUTPUT);
pinMode(klingelA, OUTPUT);
pinMode(klingelB, OUTPUT);
sei();
TCCR1B = (_BV(CS12)); //timer at Fcpu/256
Serial.begin(115200);
}
void scheduleTimerInterrupt(void){
OCR1A = (unsigned int)TCNT1 + (unsigned int)klingelPeriod;
}
void startKlingel(void){
scheduleTimerInterrupt();
TIFR1 |= _BV(OCF1A);
TIMSK1 |= _BV(OCIE1A);
digitalWrite(klingelEn, HIGH);
digitalWrite(klingelA, HIGH);
digitalWrite(klingelB, LOW);
}
void stopKlingel(void){
TIMSK1 &= ~_BV(OCIE1A);
digitalWrite(klingelEn, LOW);
}
ISR(TIMER1_COMPA_vect){
PORTD ^= (_BV(5) | _BV(6));
scheduleTimerInterrupt();
}
int gabel = 0;
void loop(void){
int g;
if (Serial.available()){
switch (Serial.read()){
case 75:
startKlingel();
break;
case 107:
stopKlingel();
break;
}
}
g = digitalRead(gabelPin);
if(g != gabel){
gabel = g;
if(g){
Serial.write("g\n");
}
else {
Serial.write("G\n");
}
}
}