Have a look at these...
http://www.arduino.cc/playground/Learning/Memory
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1281715098/4#4
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1248272002/2#2
Have you tested to ensure your code does not interfere with the proper function of random?
Have you researched how the Park-Miller algorithm functions in the face of negative values?
The EEPROM on Atmel processors is guaranteed for 100,000 cycles. If galapagos88 lives to be 100 years old, how many times per day must he play the game to reach the guaranteed lifespan?
sigh
Have a look at these...
http://www.arduino.cc/playground/Learning/Memory
http://www.arduino.cc/en/Tutorial/Memory
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1281715098/4#4
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1248272002/2#2
So what i gathered from this is that there is a different way to store all of the actors names possibly making it so that i can store more names using PROGMEM then what i have in there right now?
Is this true or am i way off base
the 25000 free bytes are in PROGMEM, so that's the way to go
alright, sorry i got busy with work and havn't had much time to fiddle with this.
I just read the arduino guide on using PROGMEM i know this is a big ol block of code but does anyone have any helpful hints on how to get the program to store the actors names into the progmem? I'm kinda super lost
#include <EEPROM.h>
#define BUTTON 4
#define rbutton 5
#define bbutton 3
int red_old = 0;
int red_new = 0;
int red_button = 0;
int blue_old = 0;
int blue_new = 0;
int blue_button = 0;
template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
int i;
for (i = 0; i < sizeof(value); i++)
EEPROM.write(ee++, *p++);
return i;
}
template <class T> int EEPROM_readAnything(int ee, T& value)
{
byte* p = (byte*)(void*)&value;
int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}
void BetterRandomSeed( void )
{
unsigned long __seed;
EEPROM_readAnything( 0, __seed );
srandom( __seed );
}
long BetterRandom( void )
{
long __seed;
__seed = random();
EEPROM_writeAnything( 0, __seed );
return( __seed );
}
long BetterRandom( long howbig )
{
if ( howbig == 0 )
{
return 0;
}
return( BetterRandom() % howbig );
}
long BetterRandom( long howsmall, long howbig )
{
if ( howsmall >= howbig )
{
return howsmall;
}
long diff = howbig - howsmall;
return( BetterRandom(diff) + howsmall );
}
char *actors[]={
"Brad Pitt",
"Edward Nortan",
"Ashton Kutcher",
"Demi Moore",
"Reese Witherspoon",
"Will Smith",
"Johnny Depp",
"Tom Hanks",
"George Clooney",
"Will Ferrell",
"Nicolas Cage",
"Leonardo DiCaprio",
"Russell Crowe",
"Tom Cruise",
"Jim Carrey",
"Chris Pine",
"Nicole Kidman",
"Jude Law",
"Julia Roberts",
"Kiefer Sutherland",
"Will Arnett",
"Michael C. Hall",
"Danny Devito",
"Pierce Brosnan",
"Daniel Craig",
"Sean Bean",
"Russell Crowe",
"Christian Bale",
"Bruce Willis",
"John Cusack",
"Samuel L. Jackson",
"Zooey Deschanel",
"Joseph Gordon-Levitt",
"Josh Hartnett",
"Steve Carell",
"Mike Myers",
"Dennis Quaid",
"Billy Bob Thornton",
"Brendan Fraser",
"Jason Statham",
"Eddie Murphy",
"Adam Sandler",
"Leonardo Dicaprio",
"Shia Labeouf",
"Matt Damon",
"Ben Affleck",
"Chris Cooper",
"Ryan Phillipe",
"Kristen Bell",
"Kristen Stewart",
"Timothy Olyphant",
"George Clooney",
"Jake Gyllenhaal",
"Clive Owen",
"Jody Foster",
"Matthew Mcconaughey",
"Jamie Foxx",
"Heath Ledger",
"Tina Fey",
"Keanu Reeves",
"Jack Nicholson",
"Mark Wahlberg",
"Justin Long",
"Vince Vaughn",
"Michael Douglas",
"Brittany Murphy",
"Viggo Mortensen",
"Val Kilmer",
"Steve Buscemi",
"William H. Macy",
"channing Tatum",
"Jackie Chan",
"Jet Lee",
"Mila Kunis",
"Jason Segel",
"Russell Brand",
"Jonah Hill",
"Casey Affleck",
"Morgan Freeman",
"Clint Eastwood",
"Simon Pegg",
"Andy Sandberg",
"isla Fisher",
"Harrison Ford",
"Jeff Goldblum",
"Eli Roth",
"Colin Farrell",
"Ralph Fiennes",
"Tommy Lee Jones",
"Ewan McGregor",
"Scarlett Johansson",
"Robert Downey jr",
"Terrence Howard",
"Jeff Bridges",
"Don Cheadle",
"Hayden Christensen",
"Michael Cera",
"Ellen Page",
"Michael J. Fox",
"Christopher Lloyd",
"Amy Smart",
"Anna Faris",
"Keira Knightley",
"Jennifer Garner",
"Orlando Bloom",
"Naomi Watts",
"Jack Black",
"Mel Gibson",
};
long actor1;
long actor2;
int val = 0;
void setup()
{
Serial.begin( 9600 );
BetterRandomSeed();
Serial.println( "Six Degrees of Seperation" );
}
void loop()
{
val = digitalRead(BUTTON);
if (val == HIGH)
{
actor1 = BetterRandom(sizeof(actors)/sizeof(char*));
do
{
actor2 = BetterRandom(sizeof(actors)/sizeof(char*));
}
while ( actor2 == actor1 );
Serial.println();
Serial.println(actors[actor1]);
Serial.println();
Serial.println(actors[actor2]);
Serial.println("______________________");
delay(1000);
Serial.println();
Serial.println("Who Won?");
Serial.println();
delay(500);
Serial.println("Red");
Serial.println(red_old);
Serial.println("Blue");
Serial.println(blue_old);
Serial.println("_______________");
delay( 500 );
}
red_button = digitalRead(rbutton);
if (red_button == HIGH)
{
Serial.println("Red");
red_new = (red_old + 1);
Serial.println(red_new);
red_old = (red_new);
Serial.println("Blue");
Serial.println(blue_old);
delay(500);
}
blue_button = digitalRead(bbutton);
if (blue_button == HIGH)
{
Serial.println("Red");
Serial.println(red_old);
Serial.println("Blue");
blue_new = (blue_old + 1);
Serial.println(blue_new);
blue_old = (blue_new);
delay(500);
}
}
thanks again
sp. "Edward Norton"
quick question if anyone knows the answer.
I finally got an lcd to hook up so i don't have to use the computer, i hooked it up like an lcd with the million i/o ports that it uses. However i was wondering if the one i got can also be used as a 1 i/o serial lcd.
i have this one
http://www.seeedstudio.com/depot/lcd-162-characters-green-yellow-back-light-p-62.html?cPath=93_98
i saw things on arduinos website just connecting the arduino tx to the lcd rx, but i cannot find an rx on the lcd.
Anyone got any ideas?
but i cannot find an rx on the lcd.
Then it's not capable of serial communication and you will have to stick with 8 bit or 4 bit data transfer.
grrr i've been misinformed lol i was told any lcd like that could be used as serial. back to the drawin board lol
So is there any benefit to using the million i/o lcd over a serial display? Other then cost
You can purchase serial lcd controller boards that will allow your existing lcd to be used with serial I/O:
And of course there are LCD displays avalible that build in their own serial controller. And yes the main difference is in the added cost for the serial controller. It's a trade off if you have enough spare I/O pins or not.
Lefty
Alright so with the exception of still not being able to figure out progmem it is all working, and all hooked up to a 20x4 character lcd. i'll post video of it running once i get my last step done.
now it is time to try and make a final pcb controller so i don;t have to try and fit a 30 arduino inside the thing.
i download the schematic for the arduino and it seems a little more hefty then what i would need.
does anyone have a schematic that just shows the bare minimum like how the atmega 328 is connected and how to run that to a usb?
or any websites that might be able to walk me through it. i know it is not super simple but there has got to be an eaiser way then deciphering the schematic that arduino puts out.
thanks!
Alright, so close i can taste it, pictures coming very soon. So i've got the button board designed, and the micro-controller board desigined.
The only question i ask is about my board. I had Eagle drawn the leads and it made it double sided. Which is fine cause i am having it printed. However, i am worried about the connection, seeing as how i am still pretty new to this my question is do i need to put in vias or will i be able to solder all of the components to one side and still be fine because the connection points maybe work as vias?
here is a pic

like always thanks a lot for all the help
No one is probably still following this thread, but if you are I've got a working prototype. Here is a quick video, sorry about the verticalness lol i recorded it on my ipod. just click it and it will launch on photobucket (i can't get my youtube account working).
I had a board printed for the arduino based controller but i messed it up so i just made one instead, the button board was printed by seeedstudio. I just need to make a box and fix some programing bugs and it will be all set! Thanks for all the help!
-Tim
Thanks for the follow-up.