Bracelet Prop:
had trouble using the Dc-Dc convertor, it worked fine for simple LED blinking, but the IR detector would not work with that supply, even with filtering caps thrown in. O suppose there was too much ripples. It only started working when power was supplied from the TI Launchpad, or from the 4931 hooked up to provide 3.3V from the 9V battery.
using the sony remote, tow 2 rows of buttons: ---------------------------------------------- 2068 1599 2069 2224 2225 1585 motor switch ------------- IN4001 1K resistor TIP31 NPN transistor leds: ------- 100 ohm resistors IR detector: ------------ 380? pins are output GND Vcc when placed with pins facing downward, and looking at lens output connected through 220ohm resistor to digital in. regulator: ----------- L4931 using m430G2553 ouside of launchpad: ------------------------------------ - add a 0.1uF capacitor (markd 104) between Vcc and GND as close to the chip as possible. - tie the RST pin to Vcc through a 47k resistor. (schematic also showed RST being tied to GND through a 1nF or 10nF capacitor) energia listing for msp430 2533 const int R_PIN = 3; // P1_3 const int G_PIN = 4; // P1_4 const int B_PIN = 5; // P1_5 const int L_PIN = 6; // P1_6 // const int LATCH_DWELL = 180; // int r_state = 0; int g_state = 0; int b_state = 0; // void setup() { Serial.begin(9600); pinMode(R_PIN, OUTPUT); pinMode(G_PIN, OUTPUT); pinMode(B_PIN, OUTPUT); pinMode(L_PIN, OUTPUT); digitalWrite(R_PIN, LOW); digitalWrite(G_PIN, LOW); digitalWrite(B_PIN, LOW); digitalWrite(L_PIN, LOW); } // void loop() { if (Serial.available() > 0) { char incoming = Serial.read(); switch (incoming) { case 'R': togglePin(R_PIN); break; case 'G': togglePin(G_PIN); break; case 'B': togglePin(B_PIN); break; case 'L': digitalWrite(L_PIN, HIGH); delay(LATCH_DWELL); digitalWrite(L_PIN, LOW); break; default: break; } } } // void togglePin(int pinToToggle) { int toggleToState = 0; switch (pinToToggle) { case R_PIN: toggleToState = r_state = !r_state; break; case G_PIN: toggleToState = g_state = !g_state; break; case B_PIN: toggleToState = b_state = !b_state; break; default: return; break; } digitalWrite(pinToToggle, toggleToState); } const int R_PIN = P1_3; // P1_3 const int G_PIN = P1_4; // P1_4 const int B_PIN = P1_5; // P1_5 const int L_PIN = P1_6; // P1_6 // const int LATCH_DWELL = 180; // int r_state = 0; int g_state = 0; int b_state = 0; // void setup() { Serial.begin(9600); pinMode(R_PIN, OUTPUT); pinMode(G_PIN, OUTPUT); pinMode(B_PIN, OUTPUT); pinMode(L_PIN, OUTPUT); digitalWrite(R_PIN, LOW); digitalWrite(G_PIN, LOW); digitalWrite(B_PIN, LOW); digitalWrite(L_PIN, LOW); } // void loop() { if (Serial.available() > 0) { char incoming = Serial.read(); switch (incoming) { case 'R': togglePin(R_PIN); break; case 'G': togglePin(G_PIN); break; case 'B': togglePin(B_PIN); break; case 'L': digitalWrite(L_PIN, HIGH); delay(LATCH_DWELL); digitalWrite(L_PIN, LOW);Uploading your video. 8 minutes remaining. Your video will be live at: break; default: break; } } } // void togglePin(int pinToToggle) { int toggleToState = 0; switch (pinToToggle) { case R_PIN: toggleToState = r_state = !r_state; break; case G_PIN: toggleToState = g_state = !g_state; break; case B_PIN: toggleToState = b_state = !b_state; break; default: return; break; } digitalWrite(pinToToggle, toggleToState); } const int R_PIN = P1_3; // P1_3 const int G_PIN = P1_4; // P1_4 const int B_PIN = P1_5; // P1_5 const int L_PIN = P1_6; // P1_6 // const int LATCH_DWELL = 180; // int r_state = 0; int g_state = 0; int b_state = 0; // void setup() { pinMode(R_PIN, OUTPUT); pinMode(G_PIN, OUTPUT); pinMode(B_PIN, OUTPUT); pinMode(L_PIN, OUTPUT); digitalWrite(R_PIN, LOW); digitalWrite(G_PIN, LOW); digitalWrite(B_PIN, LOW); digitalWrite(L_PIN, LOW); } // void loop() { togglePin(R_PIN); delay(500); togglePin(G_PIN); delay(500); togglePin(B_PIN); delay(500); digitalWrite(L_PIN, HIGH); delay(LATCH_DWELL); digitalWrite(L_PIN, LOW); delay(500); } // void togglePin(int pinToToggle) { int toggleToState = 0; switch (pinToToggle) { case R_PIN: toggleToState = r_state = !r_state; break; case G_PIN: toggleToState = g_state = !g_state; break; case B_PIN: toggleToState = b_state = !b_state; break; default: return; break; } digitalWrite(pinToToggle, toggleToState); } #define IR_BIT_LENGTH 12 // number of bits sent by IR remote #define BIT_1 1000 // Binary 1 threshold (Microseconds) #define BIT_0 400 // Binary 0 threshold (Microseconds) #define BIT_START 2000 // Start bit threshold (Microseconds) // const int R_PIN = P1_3; const int G_PIN = P1_4; const int B_PIN = P1_5; const int L_PIN = P1_6; const int IR_PIN = P2_2; // const int LATCH_DWELL = 180; // int r_state = 0; int g_state = 0; int b_state = 0; // void setup() { pinMode(R_PIN, OUTPUT); pinMode(G_PIN, OUTPUT); pinMode(B_PIN, OUTPUT); pinMode(L_PIN, OUTPUT); pinMode(IR_PIN, INPUT); digitalWrite(R_PIN, LOW); digitalWrite(G_PIN, LOW); digitalWrite(B_PIN, LOW); digitalWrite(L_PIN, LOW); } // void loop() { int key = get_ir_key(); switch (key) { case 2224: // "|<<" togglePin(R_PIN); break; case 2225: // ">>|" togglePin(G_PIN); break; case 1585: // "DBFB" togglePin(B_PIN); break; case 1599: // "SURROUND" digitalWrite(L_PIN, HIGH); delay(LATCH_DWELL); digitalWrite(L_PIN, LOW); break; default: break; } delay(150); // short delay to cancel duplicate keypresses } // void togglePin(int pinToToggle) { int toggleToState = 0; switch (pinToToggle) { case R_PIN: toggleToState = r_state = !r_state; break; case G_PIN: toggleToState = g_state = !g_state; break; case B_PIN: toggleToState = b_state = !b_state; break; default: return; break; } digitalWrite(pinToToggle, toggleToState); } /* wait for a keypress from the IR remote, and return the integer mapping of that key */ int get_ir_key() { int pulse[IR_BIT_LENGTH]; int bits[IR_BIT_LENGTH]; do {} //Wait for a start bit while(pulseIn(IR_PIN, LOW) < BIT_START); read_pulse(pulse, IR_BIT_LENGTH); pulse_to_bits(pulse, bits, IR_BIT_LENGTH); return bits_to_int(bits, IR_BIT_LENGTH); } /* use pulseIn to receive IR pulses from the remote. Record the length of these pulses (in ms) in an array */ void read_pulse(int pulse[], int num_bits) { for (int i = 0; i < num_bits; i++) pulse[i] = pulseIn(IR_PIN, LOW); } /* IR pulses encode binary "0" as a short pulse, and binary "1" as a long pulse. Given an array containing pulse lengths, convert this to an array containing binary values */ void pulse_to_bits(int pulse[], int bits[], int num_bits) { for (int i = 0; i < num_bits ; i++) { if (pulse[i] > BIT_1) //is it a 1? bits[i] = 1; else if (pulse[i] > BIT_0) //is it a 0? bits[i] = 0; else //data is invalid... ; } } // convert an array of binary values to a single base-10 integer int bits_to_int(int bits[], int num_bits) { int result = 0; int seed = 1; for(int i = 0 ; i < num_bits ; i++) { if(bits[i] == 1) result += seed; seed *= 2; } return result; } #define IR_BIT_LENGTH 12 // number of bits sent by IR remote #define BIT_1 1000 // Binary 1 threshold (Microseconds) #define BIT_0 400 // Binary 0 threshold (Microseconds) #define BIT_START 2000 // Start bit threshold (Microseconds) #define IR_PIN 7 // Sensor pin 1 wired through a 220 ohm resistor int output_key = 0; // flag to print decoded key integers void setup() { pinMode(IR_PIN, INPUT); Serial.begin(9600); } void loop() { int key = get_ir_key(); do_response(key); delay(150); // short delay to cancel duplicate keypresses } /* wait for a keypress from the IR remote, and return the integer mapping of that key */ int get_ir_key() { int pulse[IR_BIT_LENGTH]; int bits[IR_BIT_LENGTH]; do {} //Wait for a start bit while(pulseIn(IR_PIN, LOW) < BIT_START); read_pulse(pulse, IR_BIT_LENGTH); pulse_to_bits(pulse, bits, IR_BIT_LENGTH); return bits_to_int(bits, IR_BIT_LENGTH); } /* respond to specific remote-control keys with different behaviors */ void do_response(int key) { switch (key) { case 3451: // left scroll Serial.println("toggle left scroll"); break; case 3452: // right scroll Serial.println("toggle right scroll"); break; case 3339: // ok button Serial.println("toggle ok key"); break; default: Serial.print("Key "); Serial.print(key); Serial.println(" not programmed"); break; } } /* use pulseIn to receive IR pulses from the remote. Record the length of these pulses (in ms) in an array */ void read_pulse(int pulse[], int num_bits) { for (int i = 0; i < num_bits; i++) pulse[i] = pulseIn(IR_PIN, LOW); } /* IR pulses encode binary "0" as a short pulse, and binary "1" as a long pulse. Given an array containing pulse lengths, convert this to an array containing binary values */ void pulse_to_bits(int pulse[], int bits[], int num_bits) { Serial.println("-----"); for(int i = 0; i < num_bits ; i++) { Serial.println(pulse[i]); if(pulse[i] > BIT_1) //is it a 1? bits[i] = 1; else if(pulse[i] > BIT_0) //is it a 0? bits[i] = 0; else//data is invalid... Serial.println("Error"); } } // convert an array of binary values to a single base-10 integer int bits_to_int(int bits[], int num_bits) { int result = 0; int seed = 1; for(int i = 0 ; i < num_bits ; i++) { if(bits[i] == 1) result += seed; seed *= 2; } return result; } using the sony remote 2068 1599 2069 2224 2225 1585