Show Posts
Pages: 1 ... 12 13 [14] 15
196  Using Arduino / Programming Questions / Re: Need some maths help please! on: April 07, 2012, 09:18:09 am
That looks like exactly what I need! Thanks, I'll play with it now. I couldn't for the life of me figure out how to format the damn statements to do what I want.

Lifesaver!  smiley-cool
197  Using Arduino / Programming Questions / Need some maths help please! (RESOLVED) on: April 07, 2012, 08:59:44 am
This might sound pretty stupid, but I actually don't know WHAT to google to get a simple answer, so hopefully you guys can help me out :-) I bet it's one of those things that's really obvious once I know, but I'm hungover and my brain's not firing on all cylinders... hehe

Anyway, let's say I have a 4 digit number for example 1234. I want to split this up into thousands, hundreds, tens and units across 4 variables, ending up with each one holding a value of 0-9 so I can then push these out to my 7-segment module.

There MUST be a nice neat operation to do this, but hell if I can find it :-P Thanks in advance for the help!

EDIT: Here's the code I'm fiddling with, it should be apparent what I'm trying to accomplish.

Code:
int CLK = 10;
int SIN = 11;
int LAT = 12;

byte digitData[10] = {
  0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x67
};

// Array to hold segment patterns for digits 0 - 9


void setup () {
  
  pinMode(CLK, OUTPUT);
  pinMode(SIN, OUTPUT);
  pinMode(LAT, OUTPUT);
  
  
}



void loop () {
  
  while(1) {
  
unsigned long time = (millis() / 1000);

int D0 = time ?????????????

int D1 = time ?????????????

int D2 = time ?????????????

int D3 = time ?????????????


  
  digitalWrite(LAT, LOW);
  shiftOut(SIN, CLK, MSBFIRST, digitData[D0]);
 
  shiftOut(SIN, CLK, MSBFIRST, digitData[D1]);

  shiftOut(SIN, CLK, MSBFIRST, digitData[D2]);

  shiftOut(SIN, CLK, MSBFIRST, digitData[D3]);
  digitalWrite(LAT, HIGH);
  
  
  }
  
  
  
    
}


198  Using Arduino / Microcontrollers / Re: ATmega328p with 8MHz internal clock on: April 04, 2012, 03:10:03 pm
Well EXCUSE ME  smiley-razz Maybe I'm the only one who gets tired having to hack and bodge every damn thing and actually WANTS the proper tool to hand once in a while  smiley-razz
199  Using Arduino / Microcontrollers / Re: ATmega328p with 8MHz internal clock on: April 04, 2012, 12:43:59 pm
As a side-note, why not invest in an AVRisp MkII programmer next time you have a few bucks knocking around? They're hardly expensive and might make easier work of re-bootloadering things. Been meaning to get one myself for just that purpose. It's good to know all the bodges and workarounds of course, but it's also good to have a nice stash of tools smiley-grin
200  Using Arduino / Microcontrollers / Re: ATmega328p with 8MHz internal clock on: April 04, 2012, 11:53:23 am
Have you already burned a bootloader onto the chip with specific settings to use it's 8MHz internal clock? If not, try that first.
201  Using Arduino / Programming Questions / Re: Store a value on: March 29, 2012, 03:05:34 pm
As I understand it, the Flash memory and EEPROM are completely separate entities. So anything you store in EEPROM will stay there until you clear it or overwrite it.
202  Using Arduino / General Electronics / Re: Arduino timed smokebomb on: March 29, 2012, 02:46:57 pm


A very early and ugly breadboard prototype smiley I've refined the code a fair bit, and using a Pro Mini and a small serial-enabled LED module my final build should be quite small. I'm looking forward to having some production models done to take to games!
203  Using Arduino / General Electronics / Re: Arduino timed smokebomb on: March 29, 2012, 01:44:57 pm
Post pics of yours when it's done smiley-grin Would be interesting to compare notes. I'm in the process of miniaturising mine now, so it can be used in a hand-held "stick it to the wall, set it and run" sort of fashion.

Wondering if I should use the external interrupt features to devise some sort of anti-handling feature.... mmm naughty.  smiley-twist

Just checked my datasheets and the TIC106 I mentioned can handle 30A surge, 5A continuous. Might be worth considering for future projects as you'll find it pretty difficult to kill one in your chosen application!
204  Using Arduino / General Electronics / Re: Arduino timed smokebomb on: March 29, 2012, 01:17:11 pm
Any TO-220 type - MOSFET or NPN use 4 A or more.

This.

I've made stuff like this before and have several projects in the pipeline for this purpose! (Although I use Mk5 maroons typically, rather than smokes).

My personal choice is an IRF540N N-channel MOSFET, but I have also used a TIC106 SCR to accomplish the same ends. The igniters I use obliterate themselves open-circuit after firing, so the SCR will turn off when the job is done smiley
205  Using Arduino / Displays / Re: Serial display driving problems on: February 18, 2012, 02:58:38 pm
Yeah! For any timer project, you've gotta have the beeps and bloops. Especially if it's destined to be used for war games for that "movie prop" feel.

Here's what I've got going on code-wise at the moment:

Code:

const int SDATA = 12;            //pin definitions, treating the DSP-0801 like a giant shift register
const int CLOCK = 11;
const int LATCH = 10;

int t_minutes = 0;               //set up timekeeping variables, available to all functions (not used yet!)
int u_minutes = 0;
int t_seconds = 0;
int u_seconds = 0;

void setup () {
  
  pinMode(SDATA, OUTPUT);    //set those pins to output
  pinMode(CLOCK, OUTPUT);
  pinMode(LATCH, OUTPUT);
  
  
  delay(500);                                   //allow DSP-0801's onboard PIC to wake up before sending anything, seems to fix display bugs MOST of the time
  
  for(int i = 0; i < 8; i++) {                  //send 8 blank digits to clear all registers
    digitalWrite(LATCH, LOW);
    shiftOut(SDATA, CLOCK, MSBFIRST, 0x0000);   //send this value twice in 8-bit sections
    shiftOut(SDATA, CLOCK, MSBFIRST, 0x0000);
    digitalWrite(LATCH, HIGH);
  }
  
  
  int scrollRate   = 100;                                                 //defines how fast digits will scroll
  word charTable[8] = {
    0x00F7, 0x8F3, 0x1536, 0x0079, 0x120F, 0x4000, 0x4000, 0x4000 };      //character table array - what we want to put on the display goes in here
  
 
  for(int index = 0; index < 8; index++){
  word charData = charTable[index];
  
  digitalWrite(LATCH, LOW);
  shiftOut(SDATA, CLOCK, MSBFIRST, (charData >> 8));    //send high byte
  shiftOut(SDATA, CLOCK, MSBFIRST, charData);           //send low byte
  digitalWrite(LATCH, HIGH);
  delay(scrollRate);
  tone(7, 700, 10);
  
}

 tone(7, 1400, 50);
 delay(250);
 
}

 





void loop () {
  
   int scrollRate   = 100;
   word charTable[8] = {
    0x120F, 0x0038, 0x1500, 0x0000, 0x243F, 0x643F, 0x243F, 0x243F };
  
 
  for(int index = 0; index < 8; index++){
  word charData = charTable[index];
  
  digitalWrite(LATCH, LOW);
  shiftOut(SDATA, CLOCK, MSBFIRST, (charData >> 8));
  shiftOut(SDATA, CLOCK, MSBFIRST, charData);
  digitalWrite(LATCH, HIGH);
  
  }
  
  while(1) {
  }
  
  
}



206  Using Arduino / Displays / Problem solved, more or less! on: February 18, 2012, 11:09:22 am
Hey all, just thought I'd post a little update. I've put some hours in today fiddling around with code, and I think I've pretty much cracked using the display. Taught myself how to use arrays which has made things a LOT neater, and made my plans to use the hardware serial port on the arduino completely unnecessary. I also managed to sort out a problem which made the display print nothing but crap on power-up/reset most of the time by throwing in a short delay before the program starts properly. Seems to work fine now.

Thanks for bearing with me while I've thrown ideas around, it's been very helpful just having an outlet to type it all out!  smiley

Here's a short and crappy video of my progress so far:


207  Using Arduino / Displays / Re: Serial display driving problems on: February 16, 2012, 04:36:45 pm
Ok, thanks! I'll try to get something thrown together over the weekend. I think I know the sort of statements I need to be using, just not exactly how to use them! If I'm still stuck after going at it for a few hours I'll post a new thread in the relevant sub-forum :-))
208  Using Arduino / Displays / Re: Serial display driving problems on: February 16, 2012, 03:30:37 pm
Yeah, I want to use it as part of a new timer project... I've got the 4-digit 7-segment version down and it's pretty much ready for the final build, but I thought I could build something much more visually impressive using this, as I've always had a "thing" for retro-looking displays rather than LCDs.

The thing I'm stuck on now, if I continue to use the display in this mode, is how to get from the values generated by the timer program (e.g. tens of minutes, ones of minutes, tens of seconds, etc...) to characters on the display.

I've got the thing to talk to my PC over a serial terminal connection, and after fiddling with some settings I've got it to display any string I want :-D So I think that's the way I want to go... if possible, using the serialprint function to just send human-readable values straight over rather than messy look-up tables.
209  Using Arduino / Displays / Re: Serial display driving problems on: February 16, 2012, 11:55:43 am
Good job! Was the fast forward after 'L' intentional?  smiley-wink

Actually it was smiley-wink I ran out of time in the evening for messing around working out hex values for characters, so I just did a blank-and-loop! I'm getting my groove on with it now though, so I should be able to do the rest fairly quickly. I'm thinking about a metric crapload of #define statements in a header file or something so whatever program I end up writing doesn't end up stupidly long...
210  Using Arduino / Displays / Re: Serial display driving problems on: February 15, 2012, 04:04:27 pm
Excellent!

I have made some progress on this tonight, and while I would still love to use the asynchronous mode purely for the satisfaction of knowing how, I've got the damn thing to behave itself and display some characters.

Tackling the problem again with a fresh head, and a can of calm-down juice, I re-read the shiftOut tutorials and figured out what I've been doing wrong. So, using the board like a giant shift register, I made it do this:

http://www.youtube.com/watch?v=RqTqKlXYwZ8&feature=youtu.be

Which is a huge step forward from what it was doing before (either nothing, or garbage  smiley-razz )

I'll try my best not to beg to be spoon-fed without fiddling around on my own for a bit first, but I'll probably run into more problems before too long!
Pages: 1 ... 12 13 [14] 15