Show Posts
Pages: [1] 2 3 ... 11
1  Using Arduino / Microcontrollers / Re: Hacking the Info Globe on: October 17, 2011, 12:00:28 am
I gave this a try about a year ago, working off the same PIC based tutorial you found. I managed to get a little further than you. I was able to send it basic letters most of the time, but never anything very long and I'd say that only about 70% of the characters got transmitted correctly. I chalked it up to not really understanding all the timings, and sort of figured that what I really needed was a scope measuring the signals as they went back and forth so that I could adjust my timings.

For what its worth, here's my hacked up working sketch. I'll see if I can find the globe still and maybe take a picture of my base IR short and my replacement IR setup.


Code:
int ir_pin = 8; //Sensor pin 1 wired through a 220 ohm resistor
int led_pin = 12;    //"Ready to Receive" flag, not needed but nice
int debug = 1;    //Serial connection must be started to debug
int start_bit = 2400; //Start bit threshold (Microseconds)
int bin_1 = 0;    //Binary 1 threshold (Microseconds)
int bin_0_start = 760;      //Binary 0 threshold (Microseconds)
int bin_0 = bin_0_start;      //Binary 0 threshold (Microseconds)
int bin_0_tweak = 0;      //Binary 0 threshold (Microseconds)
int searchSize = 30;
int dataOut = 0;
int guardTime = 0;
int loopCount = 0;

int switchPin = 10;
bool lastSwitchState;
bool currentSwitchState;
bool ledState;

void setup() {
 pinMode(led_pin, OUTPUT); //This shows when we're ready to recieve
 pinMode(ir_pin, OUTPUT);
 digitalWrite(led_pin, LOW); //not ready yet
 digitalWrite(ir_pin, LOW);   //not ready yet
 Serial.begin(9600);
 
 pinMode(switchPin, INPUT);
 lastSwitchState = digitalRead(switchPin);
 ledState = LOW;
}

void loop() {

   checkButton();

}


int sendIRKey(int dataOut) {

  int data[8];
 digitalWrite(led_pin, HIGH);     //Ok, i'm ready to send
 for (int i=0; i<8; i++)
   //data[i] = dataOut >> (i & B1);   //encode data as '1' or '0'
   if (dataOut & (B1<<i)) {
     data[i] = 1;
   } else {
     data[i] = 0;
   }

 // send startbit
 // oscillationWrite(ir_pin, start_bit);
 // send separation bit
 //digitalWrite(ir_pin, HIGH);
 //delayMicroseconds(guardTime);
 
// startTime = millis();
 
 // send the whole string of data
 for (int i=7; i>=0; i--) {
   //digitalWrite(ir_pin, LOW);
   //if (data[i] == 0) delayMicroseconds(bin_0);
   //else delayMicroseconds(bin_1);
   if (data[i] == 0) {
      oscillationWrite(ir_pin, bin_0);
   } else {
     // oscillationWrite(ir_pin, bin_1);
     digitalWrite(ir_pin, LOW);
     delayMicroseconds(1010 - bin_1);
   }
   
   // Serial.print(data[i]);

   // send separation bit
   // digitalWrite(ir_pin, HIGH);
   // delayMicroseconds(guardTime);
 }
 
 /*
 endTime = millis();
 duration = endTime - startTime;
 Serial.print(' ');
 Serial.print(duration);
 Serial.println();
 */

 digitalWrite(led_pin, LOW);     //done sending
 // return dataOut;     //Return key number
}

// this will write an oscillation at 38KHz for a certain time in useconds
void oscillationWrite(int pin, int time) {
 for(int i = 0; i <= time/26; i++) {
   digitalWrite(pin, HIGH);
   delayMicroseconds(13);
   digitalWrite(pin, LOW);
   delayMicroseconds(13);
 }
}

void checkButton() {
  currentSwitchState = digitalRead(switchPin);
  Serial.println(currentSwitchState);
  if (currentSwitchState != lastSwitchState) {
    if (currentSwitchState == LOW) {
      // button depressed
      sendSignal();
    }
    delay(50);
  }
 
  lastSwitchState = currentSwitchState;
}

void sendSignal() {
   sendIRKey(0x01);
   //sendIRKey(0x48); // H
   //sendIRKey(0x49); // I
   
   /*
   sendIRKey(0x48); // H
   sendIRKey(0x45); // E
   sendIRKey(0x4C); // L
   sendIRKey(0x4C); // L
   sendIRKey(0x4F); // O
   sendIRKey(0x20); //
   sendIRKey(0x57); // W
   sendIRKey(0x4F); // O
   sendIRKey(0x52); // R
   sendIRKey(0x4C); // L
   sendIRKey(0x44); // D
   */
 
  /*
  bin_0_tweak++;
  if (bin_0_tweak > searchSize) {
    bin_1++;
    if (bin_1 > searchSize) {
      bin_1 = 0;
    }
    bin_0_tweak = 0;
  }
  bin_0 = bin_0_start - bin_0_tweak;
 
  Serial.print("bin_0: ");
  Serial.print(bin_0); 
  Serial.print("   bin_1: ");
  Serial.println(bin_1); 
  */
 
  delay(100);
}
2  Forum 2005-2010 (read only) / Playground Wiki / Re: Shield Pin Usage Table on: May 10, 2010, 11:49:56 pm
I do think its important to come up with some solution that can live within the Playground Wiki.  That ensures that long after we are all gone from the forum, someone else can keep things up to date.
3  Forum 2005-2010 (read only) / Playground Wiki / Re: Shield Pin Usage Table on: May 09, 2010, 10:19:11 pm
There was another recent post about shield pins:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1273360443

Based on their idea, I added a chart version of the pins to the bottom of your new page to see if the chart version works better than a listing.
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: binary output for an R/2R ladder. on: May 15, 2009, 11:41:24 pm
Is there a port that you could actually do this with on a Duemilanove?  PORTD looks like the only one where you might be able to use all 8 pins, but 0 and 1 are the serial Tx/Rx pins, so you might have to connect/disconnect them every time you uploaded a new sketch.

You could also use a shift register chip like a 74HC595 and use shiftOut.  Modified from http://www.arduino.cc/en/Reference/ShiftOut ...
Code:
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;

////Pin connected to your analog pot
int potPin = 5;

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
  pinMode(potPin, INPUT);
}

void loop() {
  potin = analogRead(potPin);
  val = map(potin, 0, 1023, 0, 255);

  //ground latchPin and hold low for as long as you are transmitting
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, MSBFIRST, val);  
  //return the latch pin high to signal chip that it
  //no longer needs to listen for information
  digitalWrite(latchPin, 1);
  delay(1000);
}

5  Forum 2005-2010 (read only) / Syntax & Programs / Re: silly LCD scrolling issue on: May 19, 2009, 11:10:12 pm
Can you post the corrected code?  Scrolling text on my LCD is something I've wanted to play with, but haven't gotten around to yet.
6  Forum 2005-2010 (read only) / Development / Re: An Introductory Tour of the Arduino Internals on: May 21, 2009, 12:07:45 am
Its a really good read.  I even understood most of it!  I'll probably have to read it a few more times to really get my head around it all.  Thanks!
7  Forum 2005-2010 (read only) / Troubleshooting / Re: LED Help on: April 16, 2010, 11:06:44 pm
Getting them to all blink in various patterns at the same time is a bit trickier.  You'll have to come up some timer variables to track how long each LED is supposed to be on, and how long it has been on.  Each cycle through the event loop, you'll check to see how long a particular LED has been on, and if it needs to be shut off at this point or not.  Similar idea for counting how long one has been off, and if its time to be turned on again.  

I wrote something conceptually similar, its a sketch that picks a random LED from a group of 32 periodically, then sets a random duration for that LED to fade on/fade off.  You can see the sketch here:

http://www.fischco.org/misc-stuff/2009/12/31/twinkling-stars-code.html

Look at the twinkle() function, that's where I'm tracking how long each LED has been on, and if its fading on or off.  Yours would be a bit simpler since you don't have to update the fade value each loop, just keep track of how long its supposed to be on/off and toggle it.

Sorry I don't have a nice simple answer for you, but that's about all I can think of so far.  Good luck!
8  Forum 2005-2010 (read only) / Troubleshooting / Re: LED Help on: April 16, 2010, 10:48:59 pm
If you only hooked up one of the LEDs, your reported behavior makes sense.  For example, if you wired up the ledPin1 LED, it would cycle through that first block of code, then continue on to execute the remaining three blocks, toggling the pins high and low, and waiting the specified times.  The fact that you don't have anything hooked up to the remaining pins just means you don't have anything to see, so you're just observing the delays.

Hook up the remaining 3 LEDs and it will probably make more sense.  smiley

The extra {  } pairs you have around each block are unneeded.  You only need a single pair of { } for the entire loop function.
9  Forum 2005-2010 (read only) / Troubleshooting / Re: LED Help on: April 16, 2010, 10:38:04 pm
Hard to say without seeing your sketch.  Go ahead and post it and we'll take a look.
10  Forum 2005-2010 (read only) / Troubleshooting / Re: Arduino mini random reset? on: June 25, 2009, 11:03:41 pm
Quote
My mini switches a light on/off every second, will I notice these resets?
I'd say try it without the pull-up resistor.  If you notice flakey behavior with it resetting, then add it in.  Experiment smiley-grin
11  Forum 2005-2010 (read only) / Troubleshooting / Re: Reset the board automatically on: May 16, 2009, 11:54:50 am
Both of those have pull-up resistors for the RESET pin on the board then.
12  Forum 2005-2010 (read only) / Troubleshooting / Re: Reset the board automatically on: May 16, 2009, 11:17:40 am
The trick will be figuring out how to only do the reset 'once per power cycle'.  So the 'first' time the sketch runs, it sets some flag, then resets itself.  The 'second' time it checks the flag state, and doesn't reset.  Tricky.

Also you don't hold the pin HIGH using the diode, that is done with a pull-up resistor that is probably already on the board.  What board are you using?
13  Forum 2005-2010 (read only) / Troubleshooting / Re: Reset the board automatically on: May 15, 2009, 08:18:03 pm
If I understand the reset correctly, the physical button resets it by bringing the RESET pin LOW.  Is it possible to connect the reset pin to one of the digital IO pins and use a digitalWrite(connect_to_reset_pin, LOW) ?
14  Forum 2005-2010 (read only) / Troubleshooting / FTDI Breakout Board & Arduino Pro Mini 3.3 Trouble on: May 02, 2009, 11:36:58 am
I just got my FTDI Breakout 3.3 this week, and it doesn't seem to be recognized by my mac, nor power the pro mini.

I have the FTDI Drivers installed, I have successfully programmed a Duemilanove and Seeeduino on this same computer.  

I'm using a Macbook Pro.

Plugging in a mini-usb to just the FTDI board alone results in flickering Tx Rx lights on the FTDI board.

Powering the Arduino Pro Mini with a battery yields the blinking pin 13 LED.  Connecting the FTDI board to the Pro Mini stops the Tx Rx lights from flashing on the FTDI board, but the pin 13 LED does not flash on the pro mini.

At no time does a tty.usbserial-XXXXXX appear as does when I connect either the Seeeduino or Duemilanove.

Am I confused about the operation of the FTDI breakout board when it is not connected to anything, should it show up as a serial port still?

I am connecting pins from BLK <-> BLK and GRN <-> GRN.



I'm stumped.
15  Forum 2005-2010 (read only) / Troubleshooting / Re: This isn't working at all... on: April 18, 2009, 10:11:53 pm
Did your last sketch uploaded use digital pins 0 or 1?
Pages: [1] 2 3 ... 11