Skip to content
Snippets Groups Projects
Commit 864a4559 authored by Mitalee Parikh's avatar Mitalee Parikh
Browse files

id update2

parent b6666b10
No related branches found
No related tags found
No related merge requests found
Pipeline #250323 passed
Input Devices
======================
This week I will use analog sensors to measure things like temperature and light using a Peizo vibration sensor and a phototransistor.
For reference, I used the Arduino love-o-meter project as it used the temperature sensor.
I started by collecting all the components.
![Gathering components](./images/input/shopping.jpeg)
I used this schematic to connect everything.
![Sketch](./images/input/schematic.jpeg)
The circuit setup was fairly easy. This is how it looks.
![setup](./images/input/setup.jpeg)docs/images/inputs/setup.jpeg
At first all lights were continuously on. I checked the serial monitor and saw that the temperature was around 26 degrees without touching. So I adjusted the baseline temperature to 25 in the sketch. After some trial and error, I adjusted the sketch so that on touching it lightly for about 5 seconds, the second led lit up and on holding it tight for some seconds the third led lit up. The serial monitor indicated temperature range from 26-32 degrees.
So an increment of 2-4-6 degrees worked out perfectly.
![serial](./images/input/serial.jpeg)
This is it in action.
![in action](./images/input/hot.gif)
####Code
[Sketch](./images/input/3leds.zip)
####Tutorials
[Arduino Project 3](https://create.arduino.cc/projecthub/godboi123/love-o-meter-bda552)
####Objective
1. measure something: add a sensor to a microcontroller board that you have designed and read it
2. probe an input device's analog levels and digital signals
#### Measuring light color using a RGB colour sensor
#Input Devices
This week, I used an Arduino board to read an analog temperature sensor.
When I have access to a lab, I will make a microcontroller board with a colour sensor as input.
###Page Summary
0. Inputs using Arduino board (no lab access)
1. Probing an input device's analog levels and digital signals
2. Designing a micro-controller board to read input
3. Milling
4. Stuffing and testing
5. Programming
6. Reading the input
7. Design Files
8. Important and Interesting Links
---
0. Inputs using Arduino board (no lab access)
---
I wanted to start with a simple project to get the basics right and understand fundamentals of using inputs with a microcontroller board. Using an Arduino Uno board with it's documentation was very basic. So I did this before designing my own board.
For reference, I used the [Arduino Project 3](https://create.arduino.cc/projecthub/godboi123/love-o-meter-bda552) as it used the temperature sensor.
I started by collecting all the components.
![Gathering components](./images/input/shopping.jpeg)
I used this schematic to connect everything.
![Sketch](./images/input/schematic.jpeg)
The circuit setup was fairly easy. This is how it looks.
![setup](./images/input/setup.jpeg)
At first, all lights were continuously on. I checked the serial monitor and saw that the temperature was around 26 degrees without touching. So I adjusted the baseline temperature to 25 in the sketch. After some trial and error, I adjusted the sketch so that on touching it lightly for about 5 seconds, the second led lit up and on holding it tight for some seconds the third led lit up. The serial monitor indicated temperature range from 26-32 degrees.
So an increment of 2-4-6 degrees worked out perfectly.
![serial](./images/input/serial.jpeg)
This is it in action:
![in action](./images/input/hot.gif)
The code was fairly simple as well. You can find it here - [Sketch](./images/input/3leds.zip)
Understanding the basics:
```
// defining constants
const int SensorPin = A1; // analog template input from temp sensor
const float BaselineTemp = 25.0; // reference temp defined
// serial port on and setup runs once
void setup(){
Serial.begin(9600); // serial monitor baud rate
for(int pinNumber = 2; pinNumber<5; pinNumber++){ // for all pins 2, 3 and 4 connected to leds
pinMode(pinNumber,OUTPUT); // define them as output
digitalWrite(pinNumber, LOW); // leds off by default
}
}
// loop - read sensor input
void loop(){
int sensorVal = analogRead(SensorPin); // read analog value from temp sensor
// serial monitor output - temperature
float voltage = (sensorVal/1024.0) * 5.0; // calculate voltage from temp sensor value
float temperature = (voltage - .5) * 100; // calculate temperature from voltage
Serial.println(temperature); // print temperatue on serial monitor
// no leds on
if(temperature < BaselineTemp){ // defining relation between input temp and reference
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
// 1 led on
else if(temperature >= BaselineTemp+2 && temperature < BaselineTemp+4){
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
}
// 2 leds on
else if(temperature >= BaselineTemp+4 && temperature < BaselineTemp+6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
// 3 leds on
else if(temperature >= BaselineTemp+6){
digitalWrite(2, HIGH);
digitalWrite(3, HIGH);
digitalWrite(4, HIGH);
}
delay(1); // delay 1/100 sec before starting loop again
}
```
1. Probing an input device's analog levels and digital signals
---
2. Designing a micro-controller board to read input
---
For this I want to try measuring light color using a RGB colour sensor.
[ATtiny412 Datasheet](https://ww1.microchip.com/downloads/en/DeviceDoc/ATtiny212-214-412-414-416-DataSheet-DS40002287A.pdf)
[VEML6040](https://www.vishay.com/docs/84276/veml6040.pdf)
#####Designing the board
Downloaded the footprint from [Here](https://www.snapeda.com/parts/VEML6040A3OG/Vishay%20Semiconductor%20Opto%20Division/view-part/702426/?company=-&amp;welcome=home)
Installed the symbol and footprint on KiCAD using [this guide](https://www.snapeda.com/about/import/#)
![libraries]()
......@@ -55,7 +116,20 @@ Installed the symbol and footprint on KiCAD using [this guide](https://www.snape
![mods](./images/input/mods.jpg)
![error](./images/input/error.jpg)
####Design Files
3. Milling
---
4. Stuffing and testing
---
5. Programming
---
6. Reading the input
---
7. Design Files
---
![traces](./images/input/inverted-traces.png)
![outline](./images/input/t412+VEML6040rgbsensor-outline.png)
[Schematic pdf](./images/input/t412+VEML6040-schematic.pdf.zip)
......@@ -63,7 +137,7 @@ Installed the symbol and footprint on KiCAD using [this guide](https://www.snape
[traces](./images/input/traces.rml.zip)
[Kicad pcbnew](./images/input/t412+VEML6040rgbsensor.kicad_pcb.zip)
#### References
8. Important and Interesting Links
---
https://en.wikipedia.org/wiki/List_of_sensors
https://hackmd.io/RzTkiKoXTbqeQOn4Nz_zAw?view#INPUTS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment