Phone: +86-20-8520 1025       Email: SALES@FRIENDLYARM.COM / techsupport@friendlyarm.com Forum    Wiki

  • Shopping Cart
  • Login
  • Register
  • CPU Module
  • Mini Board
    • Cortex-A9(Quad-Core)
    • Cortex-A8
    • ARM11
    • ARM9
  • NanoPC & NanoPi
  • Hats & Docks
  • Enclosure & Holder
    • 3D Printed
    • Acrylic
    • Metal
    • Plastic
  • Matrix Accessories
    • Actuator
    • Camera
    • Communication
    • Display
    • GPS
    • Heat Sink
    • Power
    • Sensor
    • Serial Comm Board
    • SSD/MicroSD
    • Others
  • BakeBit Sensors/Modules
  • LCD Module
  • Value Pack & Kit
FriendlyElec

Login | Register

  • Home
  • Downloads
  • Forum
  • Wiki
  • Information
    • About Us
    • Privacy Policy
    • Terms & Conditions
  • Distributor
  • FreeBoard
Joystick STK-01   Joystick STK-01   Joystick STK-01   Joystick STK-01
Joystick STK-01

Joystick STK-01

0 reviews / Write a review
  • $99,999.00
  • Availability: Out Of Stock

  • Brand: FriendlyElec
  • Product Code: STK-01


  • Description
  • Reviews (0)

1 Introduction

This module consists of two Sliding rheostats and one button. When you move the joystick the sliding rheostats' resistance will change and the corresponding x/y values will change too. When you push the joystick the SW level will turn low.

2 Features

  • two sliding rheostat and one button
  • 2.54mm spacing pin

3 How To

  • Connect to Tiny4412 SDK (1506)

    1) Please connect the Tiny4412 SDK to Matrix - Analog to Digital Converter

    2) Please connect the Joystick to Matrix - Analog to Digital Converter:

    • GND to ground
    • V to 5V
    • VRX to Analog to Digital Converter's AIN0
    • VRY to Analog to Digital Converter's AIN1
    • SW to Analog to Digital Converter's AIN2

Code Sample in C Under Linux

#include <stdio.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include "libfahw.h"
 #define SW_TRIGGER (5)
#define PS2_READ_TIMES (10)
 static int devFD;
void PS2Handler(int signNum)
{
if (signNum == SIGINT) {
printf("Quit reading PS2 rocker ");
pcf8591DeInit(devFD);
}
exit(0);
}
 int main(int argc, char ** argv)
{
int mode = 0x0;
  if ((devFD = pcf8591Init()) == -1) {
printf("Fail to init pcf8591 AD ");
return -1;
}
if (pcf8591SetCtrl(devFD, PCF8591_INIT_AD_CONTROL) == -1) {
printf("Fail to Set pcf8591 control AD ");
pcf8591DeInit(devFD);
return -1;
}
  int i = 0;
int x, y, z;
signal(SIGINT, PS2Handler);
for (i=0; i<PS2_READ_TIMES; i++) {
x = pcf8591Read(devFD, mode, PCF8591_AIN_CHANNEL0);
y = pcf8591Read(devFD, mode, PCF8591_AIN_CHANNEL1);
z = pcf8591Read(devFD, mode, PCF8591_AIN_CHANNEL2);
if (z > SW_TRIGGER) {
z = 0;
} else {
z = 0;
} else {
z = 1;
}
printf("X=%3d Y=%3d Z=%d ", x, y, z);
sleep(1);
}
pcf8591DeInit(devFD);
return 0;
}

Compile and Run

git clone http://github.com/friendlyarm/fa-hardware.git
cd fa-hardware
cd demo
cd matrix-joystick
make

Copy your compiled bin to your board and you are ready to go.

Resources


Write a review

Write a review

Note: HTML is not translated!
    Bad           Good


Power & Source of Big Ideas

Follow us
  •  
  •  
  •  
  •  
  •  
  •  
  •  
Newsletter

New in alerts - Sign up to our Newsletter.

Contact Us
  • Room 118,Building A, Shilian Technology Park, No.33 Science Road,Science City,Luogang District, Guangzhou,GuangDong China
  • +86-20-8520 1025
  • sales@friendlyarm.com
  • techsupport@friendlyarm.com
Information
  • About Us
  • Downloads
  • Privacy Policy
  • Terms&Conditions
  • Distributor
  • FreeBoard
Customer Service
  • Contact Us
  • Returns
  • Site Map
My Account
  • My Account
  • Order History
  • Wish List
  • Newsletter


Copyright © 2008-2022 friendlyelec.com All rights reserved.
Top
Categories
  • CPU Module (10)
  • Mini Board (3)
  • NanoPC & NanoPi (29)
  • Hats & Docks (13)
  • Enclosure & Holder (16)
  • BakeBit Sensors/Modules (2)
  • Matrix Accessories (73)
  • LCD Module (16)
  • Value Pack & Kit (11)