Skip to content

13. Input devices.

Task: Input Devices

The second half of the Fab Academy programme is designed to build on the previous weeks. You will be synthesisinginformation and implementing skills that you were introduced to in the first half of theprogramme and encouraged to integrate these into your final project proposal.

  • Group assignment:(Page Link is Here)
    • Probe an input device(s)’s analog and digital signals
    • Document your work to the group work page and reflect on your individual page what you learned
  • Individual assignment:
    • Measure something: add a sensor to a microcontroller board that you have designed and read it.

In this week I can learn about the details of different input devices and it’s connection, coding and it’s working principle.

What is an input device?

An input device responds to changes in the environment and produces a suitable electrical signal for processing in an electronic circuit.

In all input devices, other forms of energy are transformed into electrical energy.

My plan was use a load cell in this week. But it is not available in the inventory.

So I decided to explore some other sensors/ input devices in this week.

Potentiometer and joystick

A potentiometer is a manually adjustable variable resistor with three terminals. In our circuits we use it as a voltage divider. Basically, the voltage divider is used to turn a large voltage into a smaller one.

Untitled

A wiper moves and it divides the resistive strip as a parallel circuit. And then we can get different voltage in the output pin according to Ohm’s Law.

pot-equation.jpg

ref: randomnerdtutorials.com

Some uses of potentiometer

  • Use for volume controlling in audio equipment.
  • Use as position transducers in Joysticks.

Potentiometer joystick

It contains two potentiometers, one for each axis. The two potentiometers allow us to measure the movement of the stick in 2-D. As we move the joystick, the value of resistance of both the potentiometers changes. This change, in turn, gives us values along the X and Y axes.

The joystick gives out an analog input that is voltage varying in the range of 0 and 5v. By default, the joystick will give a value in the range of 400-600 and the value will increase or decrease as we move the joystick around. ref: thestempedia.com

https://thestempedia.com/wp-content/uploads/2018/08/2018-08-10-at-13-12-55.png

Connection

I have made a devkit board in the output programming week. I used that board this week.(Link to Board fabrication process)

For finding the pinout I referred to the datasheet and for the Arduino pin-map I used *Justin Mattair’*s Page(Link Here)

samd-pinout.jpg

Using Joystick

Diagram

joystick_3.jpg

joystick_4.jpg

Programming

Steps

  • Select SAMD21E17A board in Arduino IDE.
  • Select COM port.
  • Coding.

    ```arduino void setup() {

    SerialUSB.begin(9600); }

    void loop() {

    delay(1000);

    if (analogRead(2)> 900) { SerialUSB.println(“Up”); } if (analogRead(2)< 200) { SerialUSB.println(“Down”); }

    if (analogRead(3)> 900) { SerialUSB.println(“Right”); } if (analogRead(3)< 200) { SerialUSB.println(“Left”); } } ```

    This code is for printing different directions according to the movement of the joystick.

    I used the if statement for each direction according to different analog readings. Jowshin helped me to write this code.

  • Uploading

Control stepper motor with joystick

Connection

joy-stick_stepper-motor.jpg

Code

const int stepPin = 23;
const int dirPin = 22; 
int customDelay,customDelayMapped;

void setup() {
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);

  digitalWrite(dirPin,HIGH); 
void loop() {

  customDelayMapped = speedUp();
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(customDelayMapped);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(customDelayMapped);
}

int speedUp() {
  int customDelay = analogRead(2); 
  int newCustom = map(customDelay, 0, 1023, 300,4000);
  return newCustom;  
}

Working

I also tested some more sensors.

RCWL-0516

It is a proximity sensor that uses Dopler Radar to sense the presence of an intruder.

How it works?

The sensor emits microwaves and analyses the reflected waves to check for any changes

Connection

RCWL-dia.jpg

Code

int inPin = 23;

void setup()
{
  pinMode(inPin, INPUT);
  SerialUSB.begin(9600);

}

void loop()
{
  int reading = analogRead(inPin);
  SerialUSB.println(reading);

  delay(500);
}

Testing

Making a new board for joystick

I designed a board with joystick and SAMD11c. I also leave pins for i2c communication(SDA, SCL, VCC and GND). So I can use this board for communication week also.

Schematic

joystick-scheme.jpg

Routing and milling

joystick-2.jpg

It worked with the same code I used before.

Bill of materials

PartValueDevicePackageDescriptionAVAILABILITYDESCRIPTIONMFMPPACKAGEPRICEPURCHASE-URL
C210 mFCAP_UNPOLARIZEDFABC1206FAB
C310 mFCAP_UNPOLARIZEDFABC1206FAB
IC13.3 V 100 mAVR_REGULATOR-SOT23SOT23SOT23
JP1CONN_03X2-PINHEAD-SMD2X03SMDPIN HEADER
R1499 ohmR1206FABR1206FABResistor (US Symbol)
R2499 ohmR1206FABR1206FABResistor (US Symbol)
U$1CONN_USB_MINIBCONN_USB_MINIBUSB_MINIB
U$2LEDFAB1206LEDFAB1206LED1206FABLED
U$3CONN_02X2-PINHEAD-SMDCONN_02X2-PINHEAD-SMD2X02SMD
U$45-PIN5-PIN1X06SMD
U$6LEDFAB1206LEDFAB1206LED1206FABLED
U1UC_ATSAMD11C14A-SSUTUC_ATSAMD11C14A-SSUTSOIC127P600X160-14NMCU 32-Bit SAM D11 ARM Cortex M0+ RISC 16KB Flash 1.8V/2.5V/3.3V 14-Pin SOIC T/R Check pricesIn Stock ARM® Cortex®-M0+ SAM D11C Microcontroller IC 32-Bit 48MHz 16KB (16K x 8) FLASH 14-SOIC MicrochipATSAMD11C14A-SSUTSOIC-14 MicrochipNonehttps://pricing.snapeda.com/search/part/ATSAMD11C14A-SSUT/?ref=eda

Download files


Last update: July 5, 2022