PS2 shield exaples

Talk about Arduino board, sheilds. Sharing Arduino projects, program, problems, solutions, suggestions..... many more, all are welcome.

PS2 shield exaples

Postby matana21 » Wed Apr 15, 2015 3:08 am

hi everybody

i'm new here
can somebody please share some of working codes using the ps2?
matana21
Fledgling
 
Posts: 1
Joined: Wed Apr 15, 2015 3:05 am

Re: PS2 shield exaples

Postby KISH » Wed Apr 15, 2015 3:06 pm

CODE: SELECT_ALL_CODE
//Cytron PS2 Shield (SHIELD-PS2)
//www.cytron.com.my
//sample code to retrieve a btn status on PS2 Controller
 
#include <Shield_PS2.h>

//declare class objects
PS2 ps2=PS2();                    //PS2 class object: ps2

#define LEDPIN 13


void setup()
{
 
   ps2.init(9600, 0, 1);   //initialize the main board to use desired (baudrate, rx, tx)
                           //for Arduino Mega use RX:10, TX: 11 for software serial
                           //for Arduino Leonardo use pin 8, 9, 10, 11 as RX and TX for software serial
                             
                             
   pinMode(LEDPIN, OUTPUT);
   digitalWrite(LEDPIN,LOW);   
     
}

void loop()
{
 
  if( ps2.getval(p_select)==0)      //LED on Main Board will light up if Select button is pressed
  {
    digitalWrite(LEDPIN,HIGH);
  }
  else
  {
    digitalWrite(LEDPIN,LOW);
  }
 
 
 
}
KISH
Greenhorn
 
Posts: 2
Joined: Wed Mar 25, 2015 4:20 pm


Return to Arduino Based

Who is online

Users browsing this forum: No registered users and 21 guests

cron