CashBack Все без обмана

Плата расширения L293D, ИК-датчик VS1838B, TFT LCD, Модем M590E GSM GPRS, "монитор TFT LCD, датчик движения HC-SR501, ИК-пульт дистанционного управления, Радиомодуль NRF24L01, SD Card Module, Звуковой модуль, 5-axis stepper motor driver, Шаговый двигатель, Модем M590E GSM GPRS, 5-axis stepper motor driver, Часы реального времени DS 3231/DS 1307, терморегулятор W1209 DC, Релейный модуль, датчик движения HC-SR501, Модуль Wi-Fi ESP8266-12E, датчик движения HC-SR501, Передатчик и приемник в диапазоне RF 433 Mhz, Блок питания, L293D, Микросхема контроллера коллекторного электродвигателя, ИК-пульт дистанционного управления, Датчики контроля температуры, Радиомодуль NRF24L01, OKI 120A2, Rotary Encoder, SD Card Module, Беспроводной пульт дистанционного управления, Микросхема контроллера коллекторного электродвигателя, Модуль Bluetooth HC-06,, Модем M590E GSM GPRS, Часы реального времени DS 3231/DS 1307, Mini 360 на схеме LM2596, MP3-TF-16P, L293D, Модуль LCD монитора, Инфракрасные датчики расстояния, Часы реального времени, USB Host Shield, HC-SR501, Cветочувствительный датчик сопротивления, блок питания Mini 360 на схеме LM2596, ЖК-дисплей TFT дисплей, Контроллер L298N, HC-SR501, Модуль MP3 Player WTV020, GSM GPRS, Сервоприводы, Модем M590E GSM GPRS, Часы реального времени DS 3231/DS 1307, Модуль Wi-Fi ESP8266-12E, Инфракрасные датчики расстояния, Card Module, Ультразвуковые дальномеры HC-SR04, Блок питания, Карта памяти SD, Mini 360, Ethernet shield, L293D, блок питания Mini 360 на схеме LM2596, Радиомодуль, датчик температуры DS18B20, ИК-пульт дистанционного управления, USB конвертер UART, ИК-пульт, Антена для модуля WiFi, Ethernet shield, Модуль блока питания XL6009, Микросхема контроллера коллекторного электродвигателя, Модуль качества воздуха MQ-135, Микросхема контроллера коллекторного электродвигателя, ИК-пульт дистанционного управления, SD Card Module, Радиомодуль NRF24L01, двигатель OKI, 5-axis stepper motor driver, L293D, TB6560, Драйвер шагового двигателя TB6600, Шаговый двигатель, Модуль камеры, Блок питания, L293D, блок питания Mini 360 на схеме LM2596, 5axis mach3 interface, Карта памяти SD, Ethernet shield, Контроллер L298N, датчик движения HC-SR501, Модуль Wi-Fi ESP8266-12E, Модуль LCD монитора LCD1602, Шаговый двигатель OKI 120A2, Шаговый двигатель, Шаговый двигатель.

 

KY-023 Joystick Module

This is For PS2 game joystick module for Arduino
Lots of robot projects need joystick. This module provides a affordable solution to that. Simply connect to two analog inputs, the robot is at your commands with X,Y control. It also has a switch that is connected to a digital pin. This joystick module can be easily connect to for Arduino by normal IO Expansion Shield with supplied cables.

KY-023 Joystick Module KY-023 Joystick Module
KY-023 Joystick Module  


No soldering required, Reusable for prototyping or design applications of electronic circuit,modify or revise the circuits easily.
Accept resistors,transistors, diodes, LEDS, capacitors and other types of electronic components.
An invaluable tool for experimenting with circuit designs whether in the R&D.
Directional movements are simply two potentiometers - one for each axis
Compatible with for Arduino interface

Joystick

We have a thumb joystick that we will use. It is made up of 2 potentiometers (one for the x-axis and one for the y-axis) and a switch (for when the button is pressed).

  1. Connect the far right column to GND on the Arduino.
  2. Connect the next to right column to +5V on the Arduino.
  3. Put the Joystick breakout board in d1-d5.
  4. Connect a1 to the next to right column (+5V).
  5. Connect a2 to A5 on the Arduino..
  6. Connect a3 to A4 on the Arduino.
  7. Connect a4 to pin 2 on the Arduino.
  8. Connect a5 to the far right column (GND).

We allow for a “dead zone” in themiddle of the joystick where we don’t register

as any direction. This helps us not to have to worry about the “jitter” that is

inherent in mechanical devices. You can see the values change in the serial

monitor.

joystick/joystick.pde

 const int kPinJoystickX = A5;

 const int kPinJoystickY = A4;

 const int kPinJoystickFire = 2;

 const int JOYX_LEFT = 300;

 const int JOYX_RIGHT = 700;

 const int JOYY_UP = 700;

 const int JOYY_DOWN = 300;

 void setup()

 {

 pinMode(kPinJoystickFire, INPUT);

 digitalWrite(kPinJoystickFire, HIGH); // turn on pull-up resistor

 Serial.begin(9600);

 }

 void loop()

 {

 int xVal = analogRead(kPinJoystickX);

 int yVal = analogRead(kPinJoystickY);

 Serial.print("x = ");

 Serial.print(xVal);

 Serial.print(" y = ");

 Serial.print(yVal);

 Serial.print(’ ’);

 if(xVal < JOYX_LEFT){

 Serial.print(’L’);

 }

 else if(xVal > JOYX_RIGHT){

 Serial.print(’R’);

 }

 if(yVal < JOYY_DOWN){

 Serial.print(’D’);

 }

 Pan/Tilt bracket

 else if(yVal > JOYY_UP){

 Serial.print(’U’);

 }

 if(digitalRead(kPinJoystickFire) == LOW){

 Serial.print("+F");

 }

 Serial.println();

 delay(100); // Keep from overwhelming serial

 }

Since the readings from the joystick are within a range of 0 to 1023, we break the range down into sections. We call less than 300 LEFT (or UP), greater than 700 RIGHT (or DOWN), and just let everything in the middle count as CENTER.

The +F is to show that the joystick has been pressed down.

 

Pan/Tilt bracket

 

We have attached two servos to the pan/tilt bracket. That will allow us to pan (0-180 degrees) and tilt (0-180 degrees). Let’s combine that with the joystick for aiming.

 

(HINT: If you don’t take apart the circuit in the last section, you can start with step 9.)

 

  1. Connect the far right column to GND on the Arduino.
  2. Connect the next to right column to +5V on the Arduino.
  3. Put the Joystick breakout board in d1-d5.
  4. Connect a1 on breadboard to the next to right column (+5V).
  5. Connect a2 on breadboard to A5 on the Arduino.
  6. Connect a3 on breadboard to A4 on the Arduino.
  7. Connect a4 on breadboard to pin 2 on the Arduino.
  8. Connect a5 on breadboard to the far right column (GND).
  9. Connect the black wire of the servo on bottom (the pan servo) to the far right column (GND)
  10. Connect the red wire of the servo on bottom (the pan servo) to the next to right column (+5V)
  11. Connect the white wire of the servo on bottom (the pan servo) to pin 9 on the Arduino.
  12. Connect the black wire of the servo in the middle (the tilt servo) to the far right column (GND)
  13. Connect the red wire of the servo in the middle (the tilt servo) to the next to right column (+5V)
  14. Connect the white wire of the servo in the middle (the tilt servo) to pin 10 on the Arduino.

pantilt/pantilt.pde

#include

 const int kPinJoystickX = A5;
 const int kPinJoystickY = A4;

 const int kPinJoystickFire = 2;

 const int kPinServoPan = 9;

 const int kPinServoTilt = 10;

 const int JOYX_LEFT = 300;

 const int JOYX_RIGHT = 700;

 const int JOYY_UP = 700;

 const int JOYY_DOWN = 300;

 Servo panServo;

 Servo tiltServo;

 int panAngle = 0;

 int tiltAngle = 90;

 void setup()

 {

 panServo.attach(kPinServoPan);

 tiltServo.attach(kPinServoTilt);

 }

 void loop()

 {

 int xVal = analogRead(kPinJoystickX);

 int yVal = analogRead(kPinJoystickY);

 if(xVal < JOYX_LEFT){

 panAngle--;

 }

 else if(xVal > JOYX_RIGHT){

 panAngle++;

 }

 if(yVal < JOYY_DOWN){

 tiltAngle--;

 }

 else if(yVal > JOYY_UP){

 tiltAngle++;

 }

 tiltAngle = constrain(tiltAngle, 0, 180);

 panAngle = constrain(panAngle, 0, 180);

 panServo.write(panAngle);
 tiltServo.write(tiltAngle);
 delay(20); // wait for the servos to get there
 }

 

Our old friend the constrain() function makes sure that we keep the panAngle and the tiltAngle within the values that the servos can do.

Adding a firing mechanism


Now, we connect one more servo to actually fire the rubber band.

 

 

(HINT: If you don’t take apart the circuit in the last section, you can start with step 15)

 

1.    Connect the far right column to GND on the Arduino.

 

    2.     Connect the next to right column to +5V on the Arduino.

 

    3.     Put the Joystick breakout board in d1-d5.

 

4.    Connect a1 on breadboard to the next to right column (+5V).

  
   5.    Connect a2 on breadboard to A5 on the Arduino.

6.    Connect a3 on breadboard to A4 on the Arduino.

7.    Connect a4 on breadboard to pin 2 on the Arduino.

8.    Connect a5 on breadboard to the far right column (GND).

9.    Connect the black wire of the servo on bottom (the pan servo) to the far right column (GND).

10.    Connect the red wire of the servo on bottom (the pan servo) to the next to right column (+5V).

11.    Connect the white wire of the servo on bottom (the pan servo) to pin 9 on the Arduino.

12.    Connect the black wire of the servo in the middle (the tilt servo) to the far right column (GND).

13.    Connect the red wire of the servo in the middle (the tilt servo) to the next to right column (+5V).

14.    Connect the white wire of the servo in the middle (the tilt servo) to pin 10 on the Arduino.

15.    Connect the black wire of the servo on the top (the fire servo) to the far right column (GND).

16.    Connect the red wire of the servo on the top (the fire servo) to the next to right column (+5V).

17.    Connect the white wire of the servo on the top (the fire servo) to pin  11 on the Arduino.


rubberBandGun/rubberBandGun.pde

      #include

       const int kPinJoystickX = A5;

       const int kPinJoystickY = A4;

       const int kPinJoystickFire = 2;

       const int kPinServoPan = 9;

       const int kPinServoTilt = 10;

       const int kPinServoFire = 11;

       const int JOYX_LEFT = 300;

       const int JOYX_RIGHT = 700;

       const int JOYY_UP = 700;

       const int JOYY_DOWN = 300;

      Servo panServo;

      Servo tiltServo;

      Servo fireServo;

       int panAngle = 90;

       int tiltAngle = 90;

       int fireAngle = 0;

      void setup()

      {

               pinMode(kPinJoystickFire, INPUT);

               digitalWrite(kPinJoystickFire, HIGH); // turn on pull-up ←›

‹→   resistor

               fireServo.attach(kPinServoFire);

               fireServo.write(0);

               delay(500);

               fireServo.detach();

               panServo.attach(kPinServoPan);

               tiltServo.attach(kPinServoTilt);

      }

      void loop()

      {


               int xVal = analogRead(kPinJoystickX);

               int yVal = analogRead(kPinJoystickY);

               if(xVal < JOYX_LEFT){

                       panAngle--;

               }

               else if(xVal > JOYX_RIGHT){

                       panAngle++;

               }

               if(yVal < JOYY_DOWN){

                       tiltAngle--;

               }

               else if(yVal > JOYY_UP){

                       tiltAngle++;

               }

               tiltAngle = constrain(tiltAngle, 0, 180);

               panAngle = constrain(panAngle, 0, 180);

               panServo.write(panAngle);

               tiltServo.write(tiltAngle);

               delay(20);  // wait for the servos to get there

               if(digitalRead(kPinJoystickFire) == LOW){

                       fireServo.attach(kPinServoFire);

                       fireServo.write(180);

                       delay(500);

                       fireServo.write(0);

                       delay(500);

                       fireServo.detach();

                       while(digitalRead(kPinJoystickFire) == LOW){

                               // wait for it not to be low anymore

                       }

               }

      }

The reason why we attach and detach the firing servo is that we don’t move it very often and we don’t want to send it commands continuously when we won’t use it very often. This is for power reasons.


The fireServo.write(180) is the line that actually fires the rubber band.

Then it goes back to 0 so we can load the next rubber band on it.

     Exercises

1.     Hook up the joystick and 5 LEDs. One that shows when the joystick is pressed up, one for down, one for left, one for right, and one for fire.

2.     Make a servo do a slow sweep from 0 to 180 and then back again.

3.     CHALLENGE: After firing a rubber band, play a victory tune!

Translate

Dutch English

CashBack Реальный возврат при покупках в интернете

CashBack Все честно и без обмана