9. Input Devices

What I’ve done this week

  • tried to use input devices with the MCU board and checked them by the measuring equipment.

Weekly Assignment Requirement

Individual assignments

  • measure something: add a sensor to a microcontroller board that you have designed and read it

Group assignment

  • probe an input device’s analog levels and digital signals

Description of Assignment Work

This week, I learned input devices which would be the one of the main feature of final project in FabAcademy. For learning them, I just started to try ready-made modular kits which were sent from FabLab Kamakura because the our lab closed by the impact of Covid-19. Thanks to being sent class-kit by our instructors, I could test input devices somehow though had some limitations compared to working in the lab. And later, I have designed and cut the circuit board to run the input device for my final project.

DHT11 Temperature and humidity sensor module with Arduino

DHT11 is a sensor which can detect temperature and humidity simultaneously. It has four legs but the second one from the right end would not be used.
data sheet

I used the modular kit of DHT11 by Kuman which only had 3 legs. Usually, DHT11 needs to be connected with pull up resistor of 5.1KΩ but the module has included it already in the circuit.

I tried the sample program which I found on the internet

#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11


void setup() {
  Serial.println("DHT11 test!"); 

void loop() {

  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");

  Serial.print("Humidity: "); 
  Serial.println(" %\t");
  Serial.print("Temperature: "); 
  Serial.println(" *C ");

This program needed the library for using DHT11. I downloaded the library called “DHT-sensor-library” from GitHub.

Put the downloaded folder into own library folder as the following image.

Then run the program.

Humidity and temperature were detected.

Doppler radar with Arduino

A doppler radar transmits microwave and detects its reflection from around. If the frequency level of it got higher, it would recognize that the object is getting closer. On the contrary, if the frequency level got lower, it could understand that the object is going far away. The changes of length between the sensor and the object would make the signal to the MCU then It worked as a switch or something. So it is used as an alternative of PIR sensor for detecting human.

I couldn’t find the official datasheet for this product but there is GitHub page describing the feature of the equipment really precisely.
According to it, the pin written as 3V3 works not as a vin pin but as a 3.3V regulated output pin. And it has the holes for attaching CDS cell by default so it is easy to install to the dark situation.

I tried to use the sensor. I just wrote the simple program if the sensor detects the human turn on the LED.

int ip = 5;
int val = 0;
int led = 13;

void setup() {
  pinMode (ip, INPUT);
  pinMode (led, OUTPUT);

void loop() {
  val = digitalRead(ip);
  Serial.println(val, DEC);

  if(val !=0) {
    digitalWrite(led, HIGH);
  } else {
    digitalWrite(led, LOW);


The sensor worked correctly but its behavior was not I expected.
I wanted it to turn LED on while my hand existing in front of the sensor. but if nothing had moved in front of it, it stoped detecting because no difference was generated to the radar

Photo transistor with Barduino2.0

After a while from the first trial, I made a decision to use a photo transistor to detect the light intensity for my final project. And I also decided that I would create the mainboard based on the design of Barduino2.0 which was developed by Eduardo Chamorro Martin in FabLab Barcelona. So I soldered the sensor and the other necessary parts on the universal perfboard plates and test it with Barduino2.0.

I picked Photo transistor called PT15-21C-TR8 from the inventory.

green mark on the left meant collector. It should be headed to the plus direction. the other side was the emitter.
There was no base even it was a transistor. if it detected the light, it works as the base function of the ordinary transistor.

Neil’s board shown below was referred to the test circuit.
I tried to create it as the line I drew above. so I added 10KΩ resistor to it.

test program

#define pinA 34

void setup() {


double analogValue;
void loop() {
    analogValue = analogRead(pinA);

First model
I put the Resistor first (pull up)

Not working
showing this to my mentor later, he said it should have worked in terms of its circuit design so it might be caused by my bad soldering.

Second model
I put the transistor first (pull down)

Worked this time.
Photo transistor created more amount of current when it got light on it. larger number was coming because I used the pull down circuit. On the contrary, if I connect it as the pull up, the number which was detected from the input pin would be small.

Design the Modular Board for final project

While researching how I use a photo transistor for my final project, I found an useful information for my circuit board design from the document by Kohei Morimoto who graduated FabLab Kitakagaya in 2017. He had done with almost same idea as mine. he made small circuit board only including sensor then connected it to main board which was also designed by him. I would design the PCB similarly. One big difference was that he use normal pins for the connection but I used sockets for the connection between the mainboard and peripheral boards and a battery to hold each other firmly. Two peripheral boards were created for this time. One was for LED and the other was for photo transistor.

Here was the board design

the actual board

At the same time, I designed the main board for final project which included a MCU, ESP32. I was planning to connect the input device and the output device to it.

Here was the board design

the pin 32 was used for the output device and the pin 34 was used for the input one.

The footprints of ESP32 were too narrow to cut by CNC machine of our Lab. So I made their gaps slightly bigger by Photoshop after exporting as a png file.

the actual board

Finally, I connected two boards via cables and connecters on the boards. The phototransistor was the output device so it was connected to the pin 34.

and worked like I tested on perfboard!
So I would use this for my final project.
I put the link for the test code below.

Group Assignment

Checked hole effect sensors both analog one and digital one by the oscilloscope.
Please see the link below.

Kamakura Group assignment week09

Description of Important Weekly Learning Outcome

I could recognized lots kinds of sensors this week. I thought I had to care the type of value from them. Some of them were indicated the level of strength of their detection as an instinctive analog number (mostly like 0 to 1023). The others simply answered 0 or 1 based on their threshold level. I felt some kind of sensors have already existed or are developing to the any phenomenon. So I think it is very important to keep researching on input devices to create good inventions.

The board for phototransistor(the sub board for the output device)
Eagle sch (.sch)
Eagle brd (.brd)
Traces cutting data (.rml)
Outline cutting data (.rml)
Holes cutting data (.rml)

The main board for final project
Eagle sch (.sch)
Eagle brd (.brd)
Traces cutting data (.rml)
Outline cutting data (.rml)
Holes cutting data (.rml)