Arduino Ping Pong 16x2 LCD
Arduino Ping Pong 16x2 LCD
Componentes
1 Arduino Uno R3
1 LCD 16 x 2
5 1 kΩ Resistencia
4 Pulsador
Código:
#include <LiquidCrystal.h>
#include <avr/interrupt.h>
//----------------------------------------MACROS------------------------------------------
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); // Creating Object of type Liquid Crystal
//------------------------------------PADDLE CLASS------------------------------------------
class Paddle
{
public:
// Storing Value of each row of the Character Column for the Player's Paddle
uint8_t PaddleColArray[16] = {0,0,0,0,0,4,4,4,0,0,0,0,0,0,0,0};
//if(Player_Num == 1)
else
{
lcd.createChar(2, PaddleColArray);
lcd.createChar(3, PaddleColArray+8);
lcd.setCursor(1, 0);
lcd.write(byte(2));
lcd.setCursor(1, 1);
lcd.write(byte(3));
}
}
};
//------------------------------------PRINT_GAME CLASS------------------------------------------
class Print_Game
{
public:
//------------------------------------BALL CLASS------------------------------------------
class Ball
{
private:
public:
void PrintBall();
void AwardAPoint();
};
//---------------------------------------SETUP---------------------------------------------
void setup()
{
// The display has 2 rows with 16 characters per row
lcd.begin(16, 2);
//---------------------------------------LOOP---------------------------------------------
void loop()
{
//Printing Both Paddles
p1.PrintPaddles(Player_1);
p2.PrintPaddles(Player_2);
void P2_Move_Down()
{
p2.MovePaddleDown();
}
void P2_Move_Up()
{
p2.MovePaddleUp();
}