KS0211 keyestudio RPI JoyStick Shield: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
==keyestudio RPI JoyStick Shield==
<br>[[File:ks0211-1.png|500px|frameless|thumb]]<br>


<br>
==Introduction==
==Introduction==
Welcome to the wonderful world of joystick control. Adding a joystick to your Raspberry Pi opens a lot of new doors. You can now use the Raspberry Pi and the joystick to control a robot, a camera, play games or do whatever you want.<br>
Welcome to the wonderful world of joystick control. Adding a joystick to your Raspberry Pi opens a lot of new doors. <br>
The joystick shield provides two simple analog inputs and one analog output along with four separate buttons, one thumb joystick and two little buttons. We will provide installation package, source code and quickstart guide PDF. We will teach you step by step, so don’t worry!<br>
You can now use the Raspberry Pi and the joystick to control a robot, a camera, play games or do whatever you want. <br>
The joystick shield provides two simple analog inputs and one analog output along with four separate buttons, one thumb joystick and two little buttons. <br>
We will provide installation package, source code and quickstart guide PDF. We will teach you step by step, so don’t worry! <br>
<br>[[File:ks0211-1.png|500px|frameless|thumb]]<br>


<br>
==Specification==
==Specification==
* Chip:pcf 85911
* Chip:pcf 85911
Line 11: Line 15:
* Four separate buttons, one thumb joystick and two little buttons
* Four separate buttons, one thumb joystick and two little buttons


<br>
==Connection Diagram ==
==Connection Diagram ==
Directly plug it into the pi and max it with copper pillar and screws as shown in below figure.
Directly plug it into the pi and max it with copper pillar and screws as shown in below figure. <br>
<br>[[File:ks0211-2.png|500px|frameless|thumb]]<br>
<br>[[File:ks0211-2.png|600px|frameless|thumb]]<br>


<br>
==Sample Code==
==Sample Code==
<pre>
<pre>
Line 88: Line 94:
</pre>
</pre>


<br>
==Program Writing==
==Program Writing==
<br>
===1.Install Wiringpi Library===
===1.Install Wiringpi Library===
Wiring Pi is a library. WiringPi supports analog reading and writing, and while there is no native analog hardware on a Pi by default, modules are provided so other A/D and D/A devices can be implemented relatively easily. We will provide a Wiringpi installation package or click on this  
Wiring Pi is a library. WiringPi supports analog reading and writing, and while there is no native analog hardware on a Pi by default, modules are provided so other A/D and D/A devices can be implemented relatively easily. <br>
URL: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/ (it should open in a new page) to download the latest version. This will download a .tar file with a name like wiringPi-b0a60c3.tar. Then copy the file and put it into the raspberry pi file as shown in below figure:<br>
We will provide a Wiringpi installation package or click on this URL: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/ <br>
<br>[[File:ks0211-3.png|500px|frameless|thumb]]<br>
(it should open in a new page) to download the latest version. This will download a '''.tar''' file with a name like wiringPi-b0a60c3.tar. Then copy the file and put it into the raspberry pi file as shown in below figure:<br>
<br>[[File:ks0211-3.png|700px|frameless|thumb]]<br>
<br>
Type in this command to unzip the source code and install:<br>
Type in this command to unzip the source code and install:<br>
tar xfz wiringPi-98bcb20.tar.gz<br>
* '''tar xfz wiringPi-98bcb20.tar.gz''' <br>
cd wiringPi-98bcb20<br>
* '''cd wiringPi-98bcb20''' <br>
./build<br>
* '''./build''' <br>
Note that the actual file name will be different (may not be 98bcb20) – you will have to check the name and adjust accordingly. Here is the interface after installing WiringPi as shown in below figure.<br>
<br>
<br>[[File:ks0211-4.png|500px|frameless|thumb]]<br>
Note that the actual file name will be different (may not be 98bcb20) – you will have to check the name and adjust accordingly. <br>
Here is the interface after installing WiringPi as shown in below figure.<br>
<br>[[File:ks0211-4.png|700px|frameless|thumb]]<br>
<br>
WirtingPi includes a set of gpio commands to control the GPIO pins of the Raspberry Pi. Type in the command to check the installation:<br>
WirtingPi includes a set of gpio commands to control the GPIO pins of the Raspberry Pi. Type in the command to check the installation:<br>
gpio -v<br>
* '''gpio -v''' <br>
gpio readall<br>
* '''gpio readall''' <br>
The interface as shown in below figure means complete installation.<br>
The interface as shown in below figure means complete installation.<br>
<br>[[File:ks0211-5.png|500px|frameless|thumb]]<br>
<br>[[File:ks0211-5.png|700px|frameless|thumb]]<br>


<br>
===2.Enable I2C Utility===
===2.Enable I2C Utility===
The I2C bus allows multiple devices to be connected to your Raspberry Pi. Before using I2C it needs to be configured. Run this command: sudo raspi-config and follow the prompts to install I2C. Now complete the following steps :<br>
The I2C bus allows multiple devices to be connected to your Raspberry Pi. Before using I2C it needs to be configured. <br>
Select “9 Advanced Options”<br>
Run this command: '''sudo raspi-config''' and follow the prompts to install I2C. Now complete the following steps: <br>
Select “A6 I2C”<br>
* Select “9 Advanced Options”<br>
* Select “A6 I2C”<br>
The screen will ask if you want the ARM I2C interface to be enabled :<br>
The screen will ask if you want the ARM I2C interface to be enabled :<br>
Select “Yes”<br>
* Select “Yes”<br>
Select “Ok”<br>
* Select “Ok”<br>
Select “Finish” to return to the command line<br>
* Select “Finish” to return to the command line <br>
When you next reboot the I2C module will be loaded.<br>
When you next reboot the I2C module will be loaded.<br>


<br>
===3.Programming===
===3.Programming===
Copy the file rpi_joystick provided by us and put it into your pi directory through winSCP. Next , type this command: cd rpi_joystick to go inside the rpi_joystick folder. Then type this command: make  to make an executable file pcf8591-joytokey as shown in below figure. This means this is the file we run to launch the program. <br>
Copy the file rpi_joystick provided by us and put it into your pi directory through winSCP. Next, type this command: '''cd rpi_joystick''' to go inside the rpi_joystick folder. Then type this command: '''make''' to make an executable file pcf8591-joytokey as shown in below figure. This means this is the file we run to launch the program. <br>
Finally type this: sudo ./pcf8591-joytokey to launch the program.  
Finally type this: '''sudo ./pcf8591-joytokey''' to launch the program.  
<br>[[File:ks0211-6.png|500px|frameless|thumb]]<br>
<br>[[File:ks0211-6.png|700px|frameless|thumb]]<br>


<br>
==Result==
==Result==
Press the thumb joystick and buttons, and values are printed on the terminal as shown in below figure. Then use Ctrl+C to quit the program.
Press the thumb joystick and buttons, and values are printed on the terminal as shown in below figure. Then use '''Ctrl+C''' to quit the program.<br>
<br>[[File:ks0211-7.png|500px|frameless|thumb]]<br>
<br>[[File:ks0211-7.png|700px|frameless|thumb]]<br>


<br>
== Documents ==
== Documents ==
'''PDF File:'''
*'''PDF File:''', '''Installation Package:''' and '''Source Code:''' <br>


https://drive.google.com/open?id=14r-C7PtOPOc1xJuy7oq7Yw1z7e4ri3s6
https://fs.keyestudio.com/KS0211


'''Installation Package:'''
<br>


https://drive.google.com/open?id=18NX_KAY7dudyl78y0WBwFoGSXrZ-ZpHR
== Buy From==


'''Source Code:'''
*[https://www.keyestudio.com/keyestudio-rpi-joystick-shield-for-raspberry-pi-ce-certification-p0480-p0480.html  '''Official website''' ]


https://drive.google.com/open?id=1ZYz7mdsV4OLVkxhUa2OXMfcOP9T8cfE0
*[https://www.aliexpress.com/store/product/Keyestudio-RPI-JoyStick-Shield-for-Raspberry-Pi/1452162_32780304126.html?spm=2114.12010612.8148356.21.6e9660ffsewRl7  '''Shop on aliexpress''' ]
 
== Buy From==


http://www.keyestudio.com/keyestudio-rpi-joystick-shield.html
   
   
[[Category:Raspberry Pi]]
[[Category:Raspberry Pi]]

Latest revision as of 16:11, 3 March 2021



Introduction

Welcome to the wonderful world of joystick control. Adding a joystick to your Raspberry Pi opens a lot of new doors.
You can now use the Raspberry Pi and the joystick to control a robot, a camera, play games or do whatever you want.
The joystick shield provides two simple analog inputs and one analog output along with four separate buttons, one thumb joystick and two little buttons.
We will provide installation package, source code and quickstart guide PDF. We will teach you step by step, so don’t worry!

thumb


Specification

  • Chip:pcf 85911
  • Supply Voltage: 5V
  • Four separate buttons, one thumb joystick and two little buttons


Connection Diagram

Directly plug it into the pi and max it with copper pillar and screws as shown in below figure.

thumb


Sample Code

 #include <wiringPi.h>
#include <pcf8591.h>
#include <stdio.h>

#define Address 0x48
#define BASE 64
#define A0 BASE+0
#define A1 BASE+1
#define A2 BASE+2
#define A3 BASE+3

char dat;

int main(void)
{
        unsigned char value;
	wiringPiSetup();
        pinMode(25,INPUT);
        pinMode(7,INPUT);
        pinMode(0,INPUT);
        pinMode(2,INPUT);
        pinMode(3,INPUT);
        pinMode(4,INPUT);
        pinMode(5,INPUT);
 
        pullUpDnControl(25,PUD_UP);
        pullUpDnControl(7,PUD_UP);
        pullUpDnControl(0,PUD_UP);
        pullUpDnControl(2,PUD_UP);
        pullUpDnControl(3,PUD_UP);
        pullUpDnControl(4,PUD_UP);
        pullUpDnControl(5,PUD_UP);
	pcf8591Setup(BASE,Address);
	
	while(1)
	{
               value=analogRead(A0);              
               printf("X:%d   ",value);
               value=analogRead(A1);              
               printf("Y:%d    ",value);

               dat=digitalRead(25);
                  printf("K:%d   ",dat);

               dat=digitalRead(7);
                  printf("A:%d   ",dat);

               dat=digitalRead(0);
                  printf("B:%d   ",dat);

               dat=digitalRead(2);
                  printf("C:%d   ",dat);

               dat=digitalRead(3);
                  printf("D:%d   ",dat);


               dat=digitalRead(4);
                  printf("E:%d   ",dat);

               dat=digitalRead(5);
                  printf("F:%d\n",dat);
               delay(100);
		
               // analogWrite(BASE,value++);
               // printf("AOUT:%d\n",value++);
               // delay(50);	
	}
}


Program Writing


1.Install Wiringpi Library

Wiring Pi is a library. WiringPi supports analog reading and writing, and while there is no native analog hardware on a Pi by default, modules are provided so other A/D and D/A devices can be implemented relatively easily.
We will provide a Wiringpi installation package or click on this URL: https://projects.drogon.net/raspberry-pi/wiringpi/download-and-install/
(it should open in a new page) to download the latest version. This will download a .tar file with a name like wiringPi-b0a60c3.tar. Then copy the file and put it into the raspberry pi file as shown in below figure:

thumb

Type in this command to unzip the source code and install:

  • tar xfz wiringPi-98bcb20.tar.gz
  • cd wiringPi-98bcb20
  • ./build


Note that the actual file name will be different (may not be 98bcb20) – you will have to check the name and adjust accordingly.
Here is the interface after installing WiringPi as shown in below figure.

thumb

WirtingPi includes a set of gpio commands to control the GPIO pins of the Raspberry Pi. Type in the command to check the installation:

  • gpio -v
  • gpio readall

The interface as shown in below figure means complete installation.

thumb


2.Enable I2C Utility

The I2C bus allows multiple devices to be connected to your Raspberry Pi. Before using I2C it needs to be configured.
Run this command: sudo raspi-config and follow the prompts to install I2C. Now complete the following steps:

  • Select “9 Advanced Options”
  • Select “A6 I2C”

The screen will ask if you want the ARM I2C interface to be enabled :

  • Select “Yes”
  • Select “Ok”
  • Select “Finish” to return to the command line

When you next reboot the I2C module will be loaded.


3.Programming

Copy the file rpi_joystick provided by us and put it into your pi directory through winSCP. Next, type this command: cd rpi_joystick to go inside the rpi_joystick folder. Then type this command: make to make an executable file pcf8591-joytokey as shown in below figure. This means this is the file we run to launch the program.
Finally type this: sudo ./pcf8591-joytokey to launch the program.
thumb


Result

Press the thumb joystick and buttons, and values are printed on the terminal as shown in below figure. Then use Ctrl+C to quit the program.

thumb



Documents

  • PDF File:, Installation Package: and Source Code:

https://fs.keyestudio.com/KS0211


Buy From