Moved whole Arduino sketchbook to GIT (nothing interesting :-)
authorHarvie <tomas@mudrunka.cz>
Sun, 14 Nov 2010 10:39:17 +0000 (11:39 +0100)
committerHarvie <tomas@mudrunka.cz>
Sun, 14 Nov 2010 10:39:17 +0000 (11:39 +0100)
19 files changed:
arduino/.gitignore [new file with mode: 0644]
arduino/AM_Broadcast_Modulator/AM_Broadcast_Modulator.pde [new file with mode: 0644]
arduino/Blink/Blink.pde [new file with mode: 0644]
arduino/BrainFuck/BrainFuck.pde [moved from arduino/BrainFuck.pde with 100% similarity]
arduino/Demo01/Demo01.pde [moved from arduino/DrumMachine.pde with 100% similarity]
arduino/DrumMachine/DrumMachine.pde [new file with mode: 0755]
arduino/FM_Jammer/FM_Jammer.pde [new file with mode: 0755]
arduino/IR_Jammer/IR_Jammer.pde [moved from arduino/IR_Jammer.pde with 94% similarity, mode: 0755]
arduino/LED_Detector/LED_Detector.pde [new file with mode: 0755]
arduino/PiezoBlink/PiezoBlink.pde [new file with mode: 0755]
arduino/Pong/Pong.pde [new file with mode: 0755]
arduino/Sound/Sound.pde [moved from arduino/Sound.pde with 100% similarity]
arduino/SoundMix/SoundMix.pde [new file with mode: 0755]
arduino/TV_B_Gone/TV_B_Gone.pde [new file with mode: 0755]
arduino/dtfm/DTFM.pde [new file with mode: 0755]
arduino/led_touch/led_touch.pde [new file with mode: 0644]
arduino/oscilator/oscilator.pde [new file with mode: 0644]
arduino/serial_midi/serial_midi.pde [new file with mode: 0644]
arduino/tv_b_gone_Pedrocrespo/tv_b_gone_Pedrocrespo.pde [new file with mode: 0644]

diff --git a/arduino/.gitignore b/arduino/.gitignore
new file mode 100644 (file)
index 0000000..dc5cbd5
--- /dev/null
@@ -0,0 +1,4 @@
+*.*
+!*.pde
+!/.gitignore
+applet/
diff --git a/arduino/AM_Broadcast_Modulator/AM_Broadcast_Modulator.pde b/arduino/AM_Broadcast_Modulator/AM_Broadcast_Modulator.pde
new file mode 100644 (file)
index 0000000..3f56794
--- /dev/null
@@ -0,0 +1,176 @@
+/*Copy the code below and up load it to the I/O Board
+then put some kind of Antenna into PIN 8...PIN 8!!!!
+Then tune to AM 1337kHz.
+Optional:LED in pin 13 to see what is broadcasting,
+also a protoshield to add multiple antenna's.
+Lol that code will do morse code saying "I like ice cream";
+*********THE CODE****************************************************
+*/
+//start of code 
+//WWW.JONNYBLANCH.WEBS.COM 
+long millisAtStart = 0;
+long millisAtEnd = 0;
+
+const long period_broadcast = 8;       //period of shortest broadcast (256 port changes) 
+
+#define LENGTH_DIT 64
+//number of period_broadcasts in one 'dit', 
+//all other lengths are scaled from this 
+//Broadcasts on 1337 kHz 
+
+const int length_dit = LENGTH_DIT;     //number of periods for dit 
+const int pause_dit = LENGTH_DIT;      //pause after dit 
+const int length_dah = 3 * LENGTH_DIT; //number of persots for dah 
+const int pause_dah = LENGTH_DIT;      //pause after dah 
+const int length_pause = 7 * LENGTH_DIT;       //pause between words 
+
+void dit(void);
+void dah(void);
+void pause(void);
+void broadcast(int N_cycles);
+void dontbroadcast(int N_cycles);
+
+// ### INC ### Increment Register (reg = reg + 1) 
+#define ASM_INC(reg) asm volatile ("inc %0" : "=r" (reg) : "0" (reg))
+
+void setup() {
+
+       Serial.begin(9600);
+       DDRB = 0xFF;            //Port B all outputs 
+       //Do one dit to determine approximate frequency 
+       millisAtStart = millis();
+       dit();
+       millisAtEnd = millis();
+       Serial.print(millisAtEnd - millisAtStart);
+       Serial.print(" ");
+       Serial.print((length_dit + pause_dit) * period_broadcast * 256 /
+                    (millisAtEnd - millisAtStart) / 2);
+       Serial.print("kHz ");
+       Serial.println();
+}
+
+void loop() {
+       dit();
+       dit();
+       delay(500);
+       dit();
+       dah();
+       dit();
+       dit();
+       delay(250);
+       dit();
+       dit();
+       delay(250);
+       dah();
+       dit();
+       dah();
+       delay(250);
+       dit();
+       delay(500);
+       dit();
+       dit();
+       delay(250);
+       dah();
+       dit();
+       dah();
+       dit();
+       delay(250);
+       dit();
+       delay(500);
+       dah();
+       dit();
+       dah();
+       dit();
+       delay(250);
+       dit();
+       dah();
+       dit();
+       delay(250);
+       dit();
+       delay(250);
+       dit();
+       dah();
+       delay(250);
+       dah();
+       dah();
+       delay(2000);
+
+}
+
+void dit(void) {
+       for (int i = 0; i < length_dit; i++)
+       {
+
+               broadcast(period_broadcast);
+
+       }
+
+       for (int i = 0; i < pause_dit; i++)
+       {
+
+               dontbroadcast(period_broadcast);
+
+       }
+
+}
+
+void dah(void) {
+       for (int i = 0; i < length_dah; i++)
+       {
+
+               broadcast(period_broadcast);
+
+       }
+
+       for (int i = 0; i < pause_dah; i++)
+       {
+
+               dontbroadcast(period_broadcast);
+
+       }
+
+}
+
+void pause(void) {
+       for (int i = 0; i < length_pause; i++)
+       {
+
+               dontbroadcast(period_broadcast);
+
+       }
+
+}
+
+void broadcast(int N_cycles) {
+       unsigned int portvalue;
+       for (int i = 0; i < N_cycles; i++)
+       {
+
+               portvalue = 0;
+
+               do {
+                       PORTB = portvalue;
+                       ASM_INC(portvalue);
+               }
+               while (portvalue < 255);
+       }
+}
+
+void dontbroadcast(int N_cycles) {
+       unsigned int portvalue;
+       PORTB = 0x00;
+       for (int i = 0; i < N_cycles; i++)
+       {
+
+               portvalue = 0;
+
+               do {
+                       ASM_INC(portvalue);
+                       //add some assembly No OPerations to keep timing the same 
+                       asm volatile ("NOP");
+               }
+               while (portvalue < 255);
+       }
+}
+
+//end of code 
diff --git a/arduino/Blink/Blink.pde b/arduino/Blink/Blink.pde
new file mode 100644 (file)
index 0000000..5d27483
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+  Blink
+ Turns on an LED on for one second, then off for one second, repeatedly.
+ The circuit:
+ * LED connected from digital pin 13 to ground.
+ * Note: On most Arduino boards, there is already an LED on the board
+ connected to pin 13, so you don't need any extra components for this example.
+ Created 1 June 2005
+ By David Cuartielles
+ http://arduino.cc/en/Tutorial/Blink
+ based on an orginal by H. Barragan for the Wiring i/o board
+ */
+
+int ledPin =  13;    // LED connected to digital pin 13
+
+// The setup() method runs once, when the sketch starts
+
+void setup()   {                
+  // initialize the digital pin as an output:
+  pinMode(ledPin, OUTPUT);     
+}
+
+// the loop() method runs over and over again,
+// as long as the Arduino has power
+
+void loop()                     
+{
+  digitalWrite(ledPin, HIGH);   // set the LED on
+  delay(1000);                  // wait for a second
+  digitalWrite(ledPin, LOW);    // set the LED off
+  delay(1000);                  // wait for a second
+}
diff --git a/arduino/DrumMachine/DrumMachine.pde b/arduino/DrumMachine/DrumMachine.pde
new file mode 100755 (executable)
index 0000000..85b384a
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Bit-bang sound
+ * <~~Harvie 2oo8
+ */
+
+#define sndout 13
+
+void sound(char sndpin, float freq, float duration) { //Play bit-bang sound
+  if(duration<=0) return; if(freq<=0) { delay(duration); return; }
+  freq=((1000000/2)/freq); //Convert freq to delay (us)
+  duration*=1000; //Convert duration to us
+  pinMode(sndpin, OUTPUT);
+  for(;duration>0;duration-=2*freq) {
+    digitalWrite(sndpin, HIGH); delayMicroseconds(freq);
+    digitalWrite(sndpin, LOW);  delayMicroseconds(freq);
+  }
+  pinMode(sndpin, INPUT); //Close pin to avoid noise (optional)
+}
+
+float get_tone(char tone, char octave) { //Return tone frequency or 0
+  if(octave+tone<=0) return 0;
+  float freq;
+  switch (tone) { //THX2MS GW-BASIC Reference 4freqs muhaha ;D
+    case 'c': case 'C': freq=130.81; break;
+    case 'd': case 'D': freq=146.83; break;
+    case 'e': case 'E': freq=164.81; break;
+    case 'f': case 'F': freq=174.61; break;
+    case 'g': case 'G': freq=196; break;
+    case 'a': case 'A': freq=220; break;
+    case 'b': case 'B': freq=246.94; break;
+    default: return 0;
+  }
+  return (freq*pow(2,octave-1));
+}
+
+void play_melody(char sndpin, char *melody, char octave, int duration) {
+  for(char i=0;melody[i]!=0;i++) sound(sndpin, get_tone(melody[i], octave), duration);
+  return;
+}
+
+void setup() { // run once, when the sketch starts
+  Serial.begin(115200);
+}
+
+void play_drum(char sndpin, char drum) {
+  char c; int i; float f;
+  switch (drum) {
+    //BassDrums
+    case 'b': for(f=0;f<30;f+=4) {sound(sndpin, 60, 20); delay(f);} break;
+    case 'B': for(i=0;i<=150;i+=10) sound(sndpin, i, 10); break;
+    case 'd': for(i=150;i>=0;i-=10) sound(sndpin, i, 10); break;
+    case 'D': for(i=100;i>=40;i-=10) sound(sndpin, i, 6); break;
+    //Snares
+    case 's': for(f=0;f<1;f+=0.1) sound(sndpin, sin(f)*1000, 5); break;
+    case 'S': for(f=0;f<1;f+=0.1) sound(sndpin, sin(f)*1000+(rand()/100), 5); break;
+    case 'z': for(f=0;f<1;f+=0.15) { sound(sndpin, sin(f)*1000+(rand()/1000), 5); delay(f*10); } break;
+    //Crashes
+    case 'c': for(f=1.2;f<1.5;f+=0.01) { sound(sndpin, 700+(rand()/500), 2); delay(1/sin(f)); } break;
+    case 'C': for(f=1;f<1.3;f+=0.01) { sound(sndpin, (70+(rand()/500))*(f/0.1), 2); /*delay(1/sin(f));*/ } break;    
+    //Ambient
+    case 'r': for(i=0;i<300;i++) sound(sndpin, rand()*100, 5); break;
+    //Intros
+    case 'i': for(i=0;i<150;i++) sound(sndpin, i*100, 5); break;
+    case 'I': for(f=0;f<1;f+=0.01) {sound(sndout, sin(f)*550, 10); sound(sndout, cos(f)*400, 10); } break;
+    //Outros
+    case 'o': for(f=1;f>0.3;f-=0.01) { sound(sndpin, sin(f)*1000+(rand()/100), 5); delay(40/f); } break;
+    default: delay(100);
+  }
+}
+
+void play_rythm(char sndpin, char *rythm) {
+  for(char i=0;rythm[i]!=0;i++) play_drum(sndpin, rythm[i]);
+  return;
+}
+
+void loop() { // run over and over again
+  //delay(10000); return;//Silence! I'll kill you!
+  //while(1) sound(sndout, rand()/20, 10);
+  //int i=0; while(1) sound(sndout, i++, 10);
+  //float i=0; while(1) sound(sndout, sin(i+=0.01)*600, 10);
+  //float i=0; while(1) { sound(sndout, sin(i+=0.01)*550, 10); sound(sndout, cos(i)*400, 10); }
+  //sound(sndout, 440, 30000);
+  
+  //play_drum(sndout, 'D'); delay(1000); return;
+  //play_drum(sndout, Serial.read()); return;
+  
+  /*
+  play_rythm(sndout, "r  iI ");
+  play_melody(sndout, "c c c cc dd d eee    ", 1, 100);
+  play_rythm(sndout, "B   D   B   d s B   D s B   d c B s D C B   d S B   D S B  b s d So  ");
+  */
+  
+  sound(sndout, analogRead(0), 10); return;
+  
+/*
+  char rythm[]=
+"b "
+"D D D d D d "
+"D D D d D d "
+"i "
+"D D D d D d "
+"D D D d D d "
+"I "
+"D s D S D d "
+"D D z d D d "
+"ddDDb "
+"D D D d D s "
+"D D D d D s "
+"o";
+
+  play_rythm(sndout, rythm);
+*/
+  /*int octave, duration;
+  char melody[]="CCDEECCFFAAGGE-CCDEGGEFEDDCC-CCDEECCFFAAGGE-CCDEGGEFEDDC"; octave=1; duration=300; //Bob Marley's Redemption song - intro ;D
+  play_melody(sndout, melody, octave, duration);*/
+  delay(4000);
+}
+
diff --git a/arduino/FM_Jammer/FM_Jammer.pde b/arduino/FM_Jammer/FM_Jammer.pde
new file mode 100755 (executable)
index 0000000..1883d5a
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Blink
+ *
+ * The basic Arduino example.  Turns on an LED on for one second,
+ * then off for one second, and so on...  We use pin 13 because,
+ * depending on your Arduino board, it has either a built-in LED
+ * or a built-in resistor so that you need only an LED.
+ *
+ * http://www.arduino.cc/en/Tutorial/Blink
+ */
+
+int Pin = 13;                // LED connected to digital pin 13
+int
+
+void setup()                    // run once, when the sketch starts
+{
+  pinMode(Pin, OUTPUT);      // sets the digital pin as output
+}
+
+void loop()                     // run over and over again
+{
+    delay(1);
+    digitalWrite(Pin, HIGH);   // sets the LED onv
+    digitalWrite(Pin, LOW);    // sets the LED offv
+}
old mode 100644 (file)
new mode 100755 (executable)
similarity index 94%
rename from arduino/IR_Jammer.pde
rename to arduino/IR_Jammer/IR_Jammer.pde
index ad96955..dab2732
@@ -15,7 +15,8 @@
 #define ledpin 13
 //Maybe you will have to experiment also with this value
 int bitlen = 5;
-int d, i;
+int d;
+float i;
 
 void setup() {
   pinMode(ledpin, OUTPUT);
@@ -25,7 +26,7 @@ void loop() {
   for(d=1000/100;d<=1000/20;d++) { // 1000/frequency in kHz
   //You maybe have to experiment with ^^^ this ^^^ values
   //Frequency sweeping: 100->20 kHz works, i saw 60->1 too
-    for(i=0;i<bitlen;i++) {
+    for(i=0;i<bitlen;i+=0.5) {
       digitalWrite(ledpin, HIGH); delayMicroseconds(d/2);
       digitalWrite(ledpin, LOW ); delayMicroseconds(d/2);
     }
diff --git a/arduino/LED_Detector/LED_Detector.pde b/arduino/LED_Detector/LED_Detector.pde
new file mode 100755 (executable)
index 0000000..795e55f
--- /dev/null
@@ -0,0 +1,73 @@
+//
+// This example shows one way of using an LED as a light sensor.
+// You will need to wire up your components as such:
+//
+//           + digital2
+//           |
+//           <
+//           > 100 ohm resistor
+//           <
+//           |
+//           |
+//         -----
+//          / \  LED, maybe a 5mm, clear plastic is good
+//         -----
+//           |
+//           |
+//           + digital3
+//
+// What we are going to do is apply a positive voltage at digital2 and
+// a low voltage at digital3. This is backwards for the LED, current will
+// not flow and light will not come out, but we will charge up the 
+// capacitance of the LED junction and the Arduino pin.
+//
+// Then we are going to disconnect the output drivers from digital2 and
+// count how long it takes the stored charge to bleed off through the 
+// the LED. The brighter the light, the faster it will bleed away to 
+// digital3.
+//
+// Then just to be perverse we will display the brightness back on the 
+// same LED by turning it on for a millisecond. This happens more often
+// with brighter lighting, so the LED is dim in a dim room and brighter 
+// in a bright room. Quite nice.
+//
+// (Though a nice idea, this implementation is flawed because the refresh
+// rate gets too long in the dark and it flickers disturbingly.)
+//
+#define LED_N_SIDE 2
+#define LED_P_SIDE 3
+
+void setup()
+{}
+
+void loop()
+{
+  unsigned int j;
+
+  // Apply reverse voltage, charge up the pin and led capacitance
+  pinMode(LED_N_SIDE,OUTPUT);
+  pinMode(LED_P_SIDE,OUTPUT);
+  digitalWrite(LED_N_SIDE,HIGH);
+  digitalWrite(LED_P_SIDE,LOW);
+
+  // Isolate the pin 2 end of the diode
+  pinMode(LED_N_SIDE,INPUT);
+  digitalWrite(LED_N_SIDE,LOW);  // turn off internal pull-up resistor
+
+  // Count how long it takes the diode to bleed back down to a logic zero
+  for ( j = 0; j < 30000; j++) {
+    if ( digitalRead(LED_N_SIDE)==0) break;
+  }
+  // You could use 'j' for something useful, but here we are just using the
+  // delay of the counting.  In the dark it counts higher and takes longer, 
+  // increasing the portion of the loop where the LED is off compared to 
+  // the 1000 microseconds where we turn it on.
+
+  // Turn the light on for 1000 microseconds
+  digitalWrite(LED_P_SIDE,HIGH);
+  digitalWrite(LED_N_SIDE,LOW);
+  pinMode(LED_P_SIDE,OUTPUT);
+  pinMode(LED_N_SIDE,OUTPUT);
+  delayMicroseconds(1000);
+  // we could turn it off, but we know that is about to happen at the loop() start
+}
diff --git a/arduino/PiezoBlink/PiezoBlink.pde b/arduino/PiezoBlink/PiezoBlink.pde
new file mode 100755 (executable)
index 0000000..1b257c4
--- /dev/null
@@ -0,0 +1,14 @@
+// Fading LED 
+// by BARRAGAN <http://people.interaction-ivrea.it/h.barragan> 
+
+int ledpin = 11;                           // light connected to digital pin 9
+void setup() 
+{ 
+  pinMode(ledpin, OUTPUT);
+} 
+void loop() 
+{ 
+    analogWrite(ledpin, analogRead(0));           // sets the value (range from 0 to 255) 
+} 
diff --git a/arduino/Pong/Pong.pde b/arduino/Pong/Pong.pde
new file mode 100755 (executable)
index 0000000..66f2c8c
--- /dev/null
@@ -0,0 +1,30 @@
+/* Pong controller (for use with hPong)
+ * <~~Harvie 2oo8
+ */
+#define inpin 0
+int min = 65535, max = 0;
+int stadium_max = 14;
+char offset = 8;
+float val = 0, oldval = -255;
+
+void setup()                    // run once, when the sketch starts
+{
+  stadium_max+=offset;
+  Serial.begin(115200);
+}
+
+void loop()                     // run over and over again
+{
+  val = analogRead(inpin);
+  if(val<min) min=val;
+  if(val>max) max=val;
+  val=(((val-(min))/(max-(min)))*stadium_max)-offset;
+  if(val!=oldval) {
+    oldval = val;
+    //Serial.print(min, DEC); Serial.print("-"); Serial.print(max, DEC); Serial.print("\n");
+    //Serial.print(val, DEC); Serial.print("\n");
+    Serial.print(val, BYTE);
+  }
+  delay(1);
+}
similarity index 100%
rename from arduino/Sound.pde
rename to arduino/Sound/Sound.pde
diff --git a/arduino/SoundMix/SoundMix.pde b/arduino/SoundMix/SoundMix.pde
new file mode 100755 (executable)
index 0000000..6466151
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Bit-bang sound
+ * <~~Harvie 2oo8
+ */
+
+#define sndout 13
+
+char mixer;
+
+void sound(char sndpin, float freq, float duration) { //Play bit-bang sound
+  if(duration<=0) return; if(freq<=0) { delay(duration); return; }
+  freq=((1000000/2)/freq); //Convert freq to delay (us)
+  duration*=1000; //Convert duration to us
+  pinMode(sndpin, OUTPUT);
+  for(;duration>0;duration-=2*freq) {
+    digitalWrite(sndpin, HIGH); delayMicroseconds(freq);
+    digitalWrite(sndpin, LOW);  delayMicroseconds(freq);
+  }
+  pinMode(sndpin, INPUT); //Close pin to avoid noise (optional)
+}
+
+void setup() { // run once, when the sketch starts
+  pinMode(sndout, OUTPUT);
+  pinMode(sndout-1, INPUT);
+}
+
+void loop() { // run over and over again
+  //delay(10000); return;//Silence! I'll kill you!
+  //float i=0; while(1) { sound(sndout, sin(i+=0.01)*550, 10); sound(sndout, cos(i)*400, 10); }
+  digitalWrite(sndout, digitalRead(sndout-1));
+  /* int octave, duration;
+  char melody[]="CCDEECCFFAAGGE-CCDEGGEFEDDCC-CCDEECCFFAAGGE-CCDEGGEFEDDC"; octave=1; duration=300; //Bob Marley's Redemption song - intro ;D
+  play_melody(sndout, melody, octave, duration); */
+  //delay(2000);
+}
+
diff --git a/arduino/TV_B_Gone/TV_B_Gone.pde b/arduino/TV_B_Gone/TV_B_Gone.pde
new file mode 100755 (executable)
index 0000000..678353e
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Arduino TV-B-GONE
+ * <~~Harvie 2oo8
+ *
+ * THX 2 Ladyada
+ * http://www.ladyada.net/make/tvbgone/
+ *
+ */
+
+//#include "NAcodes.c"
+//#include "NAcodes2.c"
+#define ledpin 13
+//Maybe you will have to experiment also with this value
+int d;
+float i;
+
+void fire_code(int outpin, long freq, fuck *code) { //kHz
+  freq = 1000000/(freq*1000); //freq2millis
+  for()
+}
+
+void setup() {
+  pinMode(ledpin, OUTPUT);
+}
+
+void loop() {
+  for(d=1000/100;d<=1000/20;d++) { // 1000/frequency in kHz
+  //You maybe have to experiment with ^^^ this ^^^ values
+  //Frequency sweeping: 100->20 kHz works, i saw 60->1 too
+    for(i=0;i<bitlen;i+=0.5) {
+      digitalWrite(ledpin, HIGH); delayMicroseconds(d/2);
+      digitalWrite(ledpin, LOW ); delayMicroseconds(d/2);
+    }
+    delayMicroseconds(d*bitlen);
+  }
+}
+
diff --git a/arduino/dtfm/DTFM.pde b/arduino/dtfm/DTFM.pde
new file mode 100755 (executable)
index 0000000..0dae414
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * DTFM
+ * <~~Harvie 2oo8
+ */
+/* 
+DTMF keypad frequencies (with sound clips)
+      1209 Hz 1336 Hz 1477 Hz 1633 Hz
+697 Hz         1       2       3       A
+770 Hz         4       5       6       B
+852 Hz         7       8       9       C
+941 Hz         *       0       #       D
+
+DTMF event frequencies
+Event            Low frequency High frequency
+Busy signal            480 Hz  620 Hz
+Dial tone              350 Hz  440 Hz
+Ringback tone (US)     440 Hz  480 Hz
+*/
+
+#define dtfmpin 13
+
+void dtfm_tone(char outpin, float low, float high) {
+  int duration = 300;
+  char pin;
+  long pos, startmillis = millis();
+  while((pos = millis()-startmillis) <= duration) {
+    pin = false;
+    if( sin((pos*low)/1000*(2*PI)) > 0) pin = true;
+    if( sin((pos*high)/1000*(2*PI)) > 0) pin = true;
+    
+    if(pin) digitalWrite(outpin, HIGH); else digitalWrite(outpin, LOW);
+  }
+}
+
+int dtfm_key(char outpin, char key) {
+  switch (key) {
+    case '1': dtfm_tone(outpin, 697, 1209); break;
+    case '2': dtfm_tone(outpin, 697, 1336); break;
+    case '3': dtfm_tone(outpin, 697, 1477); break;
+    
+    case '4': dtfm_tone(outpin, 770, 1209); break;
+    case '5': dtfm_tone(outpin, 770, 1336); break;
+    case '6': dtfm_tone(outpin, 770, 1477); break;
+    
+    case '7': dtfm_tone(outpin, 852, 1209); break;
+    case '8': dtfm_tone(outpin, 852, 1336); break;
+    case '9': dtfm_tone(outpin, 852, 1477); break;
+    
+    case '*': dtfm_tone(outpin, 941, 1209); break;
+    case '0': dtfm_tone(outpin, 941, 1336); break;
+    case '#': dtfm_tone(outpin, 941, 1477); break;
+                               
+    default: return 0;
+  }
+  return 1;
+}
+
+void dtfm_dial(char outpin, char *keys) {
+  for(char i=0;keys[i]!=0;i++) { dtfm_key(outpin, keys[i]); delay(100); }
+}
+
+void setup()                    // run once, when the sketch starts
+{
+  pinMode(dtfmpin, OUTPUT);      // sets the digital pin as output
+  //dtfm_dial(dtfmpin, "739136794");
+  dtfm_tone(dtfmpin, 1, 10);
+}
+
+void loop()                     // run over and over again
+{
+delay(10000);
+}
diff --git a/arduino/led_touch/led_touch.pde b/arduino/led_touch/led_touch.pde
new file mode 100644 (file)
index 0000000..498a37a
--- /dev/null
@@ -0,0 +1,51 @@
+//TOUCH SENSING BETA - LED TURNS ON WHEN LIGHT IS PRESENT
+//BY: RICARDO DE LEMOS 1/17/2007
+int led1 = 13;
+int cath = 2; // negative
+int ando = 3;  // positive
+
+void setup()
+ {
+   pinMode(led1, OUTPUT);
+   pinMode(cath, OUTPUT);
+   pinMode(ando, OUTPUT);
+   //Serial.begin(9600);
+ }
+int dela = 20;
+int last = HIGH;
+int shine = HIGH;
+
+void loop()
+ {
+   //TURN SENSOR LED ON
+   pinMode(ando, OUTPUT);
+   if(shine) {
+     digitalWrite(cath, LOW);
+     digitalWrite(ando, HIGH);
+     delay(100);
+   }
+   
+   //REVERSE BIAS + CHARGE LED
+   digitalWrite(cath, HIGH);
+   digitalWrite(ando, LOW);
+   //delay(dela);
+   
+   //READ LED CAP
+   pinMode(ando, INPUT);
+   delay(dela);
+   int state = digitalRead(ando);
+   
+   //SWITCH
+   if((state != last) && state == LOW) shine = !shine;
+   last = state;
+   
+   //DEBUG LED
+   if(state) {
+     digitalWrite(led1,HIGH);
+   } else {
+     digitalWrite(led1,LOW);
+   }
+ }
+
diff --git a/arduino/oscilator/oscilator.pde b/arduino/oscilator/oscilator.pde
new file mode 100644 (file)
index 0000000..3c45854
--- /dev/null
@@ -0,0 +1,36 @@
+/* Pong controller (for use with hPong)
+ * <~~Harvie 2oo8
+ */
+#define inpin 0
+int min = 65535, max = 0;
+int stadium_max = 70;
+char offset = 0;
+float val = 0, oldval = -255;
+int sndPin = 12;
+
+void setup()                    // run once, when the sketch starts
+{
+  stadium_max+=offset;
+  Serial.begin(19200);
+  pinMode(sndPin, OUTPUT);
+}
+
+void loop()                     // run over and over again
+{
+  val = analogRead(inpin);
+  if(val<min) min=val;
+  if(val>max) max=val;
+  val=(((val-(min))/(max-(min)))*stadium_max)-offset;
+  /*if(val!=oldval) {
+    oldval = val;
+    //Serial.print(min, DEC); Serial.print("-"); Serial.print(max, DEC); Serial.print("\n");
+    //Serial.print(val, DEC); Serial.print("\n");
+    //Serial.print(val, BYTE);
+  }*/
+  val=val;
+  digitalWrite(sndPin, HIGH);
+  delay(val);
+  digitalWrite(sndPin, LOW);
+  delay(val);
+}
diff --git a/arduino/serial_midi/serial_midi.pde b/arduino/serial_midi/serial_midi.pde
new file mode 100644 (file)
index 0000000..4ecfcf4
--- /dev/null
@@ -0,0 +1,71 @@
+//  *****************************************************************************************************************
+//  *                                                                                                               *
+//  *                                         SpikenzieLabs.com                                                     *
+//  *                                                                                                               *
+//  *                                   Very Simple Serial to MIDI DEMO                                             *
+//  *                                                                                                               *
+//  *****************************************************************************************************************
+//
+// BY: MARK DEMERS 
+// May 2009
+// VERSION: 0.1
+//
+// DESCRIPTION:
+// Demo sketch to play notes from middle C in the 4th octave up to B in the 5th octave and then back down.
+//
+//
+// HOOK-UP:
+// 1. Plug USB cable from Arduino into your computer.
+//  
+//
+// USAGE:
+// 1. Install and Set-up Serial MIDI Converter from SpikenzieLabs
+// 2. Open, compile, and upload this sketch into your Arduino.
+// 3. Run Serial MIDI Converter in the background.
+// 4. Launch your music software such as Garage Band or Ableton Live, choose a software instrument and listen to the music.
+//
+//
+// LEGAL:
+// This code is provided as is. No guaranties or warranties are given in any form. It is up to you to determine
+// this codes suitability for your application.
+//
+
+int note = 0;     
+
+void setup() 
+{
+  Serial.begin(57600);                                       // Default speed of the Serial to MIDI Converter serial port
+}
+
+void loop() 
+{
+
+  for(int note=60; note<=83; note++)                        // Going Up
+  {
+    MIDI_TX(144,note,127);                                  // NOTE ON
+    delay(100);
+
+    MIDI_TX(128,note,127);                                  // NOTE OFF
+    delay(100);
+  }
+
+  for(int note=82; note>=61; note--)                       // Coming Down
+  {
+    MIDI_TX(144,note,127);                                  // NOTE ON
+    delay(250);
+
+    MIDI_TX(128,note,127);                                  // NOTE OFF
+    delay(250);
+  }
+
+}
+
+
+void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY) 
+{
+  Serial.print(MESSAGE);
+  Serial.print(PITCH);
+  Serial.print(VELOCITY);
+}
+
+
diff --git a/arduino/tv_b_gone_Pedrocrespo/tv_b_gone_Pedrocrespo.pde b/arduino/tv_b_gone_Pedrocrespo/tv_b_gone_Pedrocrespo.pde
new file mode 100644 (file)
index 0000000..0deb1b7
--- /dev/null
@@ -0,0 +1,309 @@
+/* Arduino TV-B-Gone
+*
+* A recreation of the TV-B-Gone kit on an Arduino Duemilanove.
+* By Daedalus12, mtbf0, westfw and Pedrocrespo
+*
+*/
+
+#include <avr/pgmspace.h>
+
+struct codeElement {
+  uint32_t onTime;   // duration of "On" time
+  uint32_t offTime;  // duration of "Off" time
+};
+
+struct powercode {
+  uint32_t freq; // frequency
+  struct codeElement codes[100];  // on/off codes, supposed to be 100 as maximum
+};
+  
+    int  i = 0; // we use this for iterating
+    long cfreq; // we'll store each frequency here when needed
+  
+const struct powercode sonyCode PROGMEM = {   
+  37470, 
+  {{245, 60},
+   {123, 60},
+   {61 , 60},
+   {123, 60},
+   {61 , 60},
+   {123, 60},
+   {61 , 60},
+   {61 , 60},
+   {123, 60},
+   {61 , 60},
+   {61 , 60},
+   {61 , 60},
+   {61 , 2759},
+   {245, 60},
+   {123, 60},
+   {61 , 60},
+   {123, 60},
+   {61 , 60},
+   {123, 60},
+   {61 , 60},
+   {61 , 60},
+   {123, 60},
+   {61 , 60},
+   {61 , 60},
+   {61 , 60},
+   {61 , 0}}
+};
+const struct powercode panasonicCode PROGMEM = {   
+   36130, 
+   {{358,179},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 135},
+   {44, 135},
+   {44, 135},
+   {44, 135},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 135},
+   {44, 135},
+   {44, 135},
+   {44, 135},
+   {44, 45},
+   {44, 135},
+   {44, 7720},
+   {358, 180},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 135},
+   {44, 135},
+   {44 ,135},
+   {44 ,135},
+   {44, 45},
+   {44, 45},
+   {44, 135},
+   {44, 45},
+   {44, 135},
+   {44, 135},
+   {44, 135},
+   {44, 135},
+   {44, 45},
+   {44, 135},
+   {44,  0}}
+};
+
+const struct powercode sony2Code PROGMEM = {
+
+  37470,
+
+  { {245,   60},
+
+    {123,   60},
+
+    {123,   60},
+
+    {123,   60},
+
+    {123,   60},
+
+    {61,   60},
+
+    {123,   60},
+
+    {61,   60},
+
+    {123,   60},
+
+    {61,   60},
+
+    {61,   60},
+
+    {61,   60},
+
+    {61,   2636},
+
+    {246,   60},
+
+    {123,   60},
+
+    {123,   60},
+
+    {123,   60},
+
+    {123,   60},
+
+    {61,   60},
+
+    {123,   60},
+
+    {61,   60},
+
+    {123,   60},
+
+    {61,   60},
+
+    {61,   60},
+
+    {61,   60},
+
+    {61,   0}  }
+
+};
+
+
+
+const struct powercode sony3Code PROGMEM = {
+
+  74940,
+
+  { {250,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    { 60,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    { 60,     63},
+
+    { 60,     63},
+
+    { 60,   2819},
+
+    {250,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    { 60,     63},
+
+    {121,     63},
+
+    { 60,     63},
+
+    { 60,     63},
+
+    { 60,     63},
+
+    { 60,      0}
+
+  }
+
+};
+PROGMEM const powercode *powerCodes[] = {
+  &sonyCode, &panasonicCode,  &sony2Code, &sony3Code
+}; // select the codes you like
+
+int num_codes = (sizeof(powerCodes)/sizeof(*powerCodes)); // count how many codes are in the list
+
+void setup() {
+  DDRD = _BV(DDD6);  // sets Pin 6 as output
+}   
+
+void loop(){
+    for(i=0;i<num_codes;i++){ //Iterate between powercodes
+       cfreq = pgm_read_word(pgm_read_word(&(powerCodes[i]))+0); // store the frequency
+       unsigned char compareVal = (F_CPU/cfreq - 1)/2; // transform it to cpu cycles
+       TCCR0A = 0;     // make sure timer is off before updating OCR0A
+       OCR0A = compareVal; // update timer
+       for (int arrayStep = 0; pgm_read_word(pgm_read_word(&(powerCodes[i]))+(8*arrayStep)+8)!=0; arrayStep++){
+         transmitCode(pgm_read_word(pgm_read_word(&(powerCodes[i]))+(8*arrayStep)+4),pgm_read_word(pgm_read_word(&(powerCodes[i]))+(8*arrayStep)+8)); // transmit the code using function described below
+       }
+   delayMicroseconds(250);// Avoid interferring a powercode and the next one if frequencies are similar
+  }
+}
+
+void transmitCode(int onTime, int offTime){
+//  transmits one element of the POWER code
+  TCNT0 = 0;                              // reset timer 0
+  TCCR0A = _BV(COM0A0) | _BV(WGM01);      // set up timer 0
+  TCCR0B = _BV(CS00);                     // turn on timer 0
+  delayMicroseconds(10*onTime);           // wait for onTime
+  TCNT0 = 0;                                // stop timer
+  TCCR0A = 0;                               // clear register A
+  TCCR0B = 0;                               // clear register B
+  PORTD = ~_BV(PORTD6);                     // turn off the LED 
+  delayMicroseconds(10*offTime);            // wait for offTime
+}
This page took 0.617488 seconds and 4 git commands to generate.