8/29/2023 0 Comments Long random words![]() So if i add any more names after Mel Gibson that's when things start getting weird. For example it seemed like every name i added past this point it would erase a line of my serial print. However when my friend and i went in to add a bunch of actors names at a certian point the program started glitching out. I added in command line for 3 buttons to control a point system, and to call the names up. After all, it isn't too difficult to find movies that include Clive Owen and Clive Owen!Īlright so everything is working great. ensures a different actor is printed for the second choice. BetterRandom( void ) calls random to get the next "random" value and saves this value to EEPROM to be used as the seed the next time setup / BetterRandomSeed is called. BetterRandomSeed reads the 32-bit seed value from EEPROM and calls srandom to set the next seed value for random. BetterRandom( long howbig ) and BetterRandom( long howsmall, long howbig ) use BetterRandom( void ) instead of random but are otherwise identical to their Arduino cousins. The four BetterRandom* functions take the place of the corresponding Arduino random* functions. In this Sketch, it's used to read the 32-bit seed from address zero. EEPROM_readAnything reads data from EEPROM into a variable of any type. In this Sketch, it's used to write the 32-bit seed value to EEPROM address zero. EEPROM_writeAnything takes a variable of any type and writes it to EEPROM. A template, in this usage, is similar to a function. srandom simply sets the seed value used the next time random is called.ĮEPROM_writeAnything and EEPROM_readAnything are templates graciously provided by halley. The returned result is the seed for the next call. random takes a 32 bit seed value, performs some math on this value, and returns the result. There are two functions of interest from "stdlib": random and srandom. The Arduino random functions are based on the functions provided in "stdlib" a library provided with most C(++) compilers. It has been too long since I needed a C(++) book for me to be able to recommend something. Serial.println( "Six Degrees of Seperation" ) Īctor1 = BetterRandom(sizeof(actors)/sizeof(char*)) Īctor2 = BetterRandom(sizeof(actors)/sizeof(char*)) Īlso if you know of any books that will help explain the programing language that would be super. Template int EEPROM_writeAnything(int ee, const T& value)Ĭonst byte* p = (const byte*)(const void*)&value įor (i = 0 i int EEPROM_readAnything(int ee, T& value) Serial.println("Six Degrees of Seperation") Īctor1 = random(sizeof(actors)/sizeof(char*)) Īctor2 = random(sizeof(actors)/sizeof(char*)) Īny ideas why it's picking the same everytime? If i keep hitting it without closing it apears to be random, but if i close and open it it still uses the same pairs in the same order. I'll turn it on and push the button and it picks 2 names and if i close the serial monitor and then open it and hit the button again it picks the same 2 names. However it seems that it always uses the same pairs. I changed the code a little so that it would pick and display 2 names. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |