12/29/2023 0 Comments Piano tiles 1000![]() ![]() Int intDelay //the time the program waits till the next turn in millisīoolean bolSerialBoard //when true will print the board in the serial monitor Int intTick //counts up millies (per loop) until intDelay Int intInput //tracks which buttons the user pressesīoolean bolTilePressed //ensure the player doesn't accidently press a button 5x and lose ![]() Int intEnter //trackes if the user presses the enter button Int intDiff //just an estetic thing for telling what difficulty the game is on Int intGameSpeedHard = 80 //set up variables for the gameboolean bolPlay //tracks if the player Now we need to declare the variables by putting the next bit of code below the object declarations: //these variables are options that you can change - higher numbers = faster game speed upint intGameSpeedEasy = 10 The numbers in the attached brackets tell the arduino which ports the object should be using to send messages to the LCD when we use their functions. What this does is tells the arduino that when we call lcdLeft or lcdRight we are refering to a LiquidCrystal object. To do this put this code below our defines LiquidCrystal lcdLeft(8, 9, 12, 10, 11, 13) LiquidCrystal lcdRight(2, 3, 4, 5, 6, 7) Next we are going to create the objects that will control the Liquid Crystal Displays. Although we are calling the ports port 15, 16, 17 and 18, they are labelled on the arduino as A1 A2 A3 and A4, this is because they are ports used specifically for analog inputs, although we are only using them for digital inputs. ![]() It means that when we type btn1 the arduino will know we in fact mean the button 15. We define the terms btnEnter and btn1 to btn 4 to make the code easier for us to read, or change if necessary. The next step is to define the pins we are using for our buttons by putting this code in below our #include: #define btnEnter A0#define btn1 15 All code here should go before your void setup and void loop, this is because all of these variables and objects are used in several of the functions we will set up.Īt the top of your code, this is telling the arduino to use the library "LiquidCrystal.h" and the functions that are a part of it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |