Skip to content
Snippets Groups Projects
Commit d2139bff authored by Adrián Torres's avatar Adrián Torres
Browse files

photo_ir_adrianino

parent 7f73e3d9
No related branches found
No related tags found
No related merge requests found
Pipeline #188526 passed
......@@ -76,6 +76,7 @@
<li><a href="#hall" class="button">Hall effect</a></li>
<li><a href="#temperature" class="button">Temperature</a></li>
<li><a href="#photo" class="button">Phototransistor</a></li>
<li><a href="#photoir" class="button">Phototransistor IR</a></li>
</ul>
......@@ -768,6 +769,60 @@ void loop() {
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/light.mp4" type="video/mp4"></video></p>
<h2><a id="photoir"></a>Phototransistor. IR.</h2>
<p>The <a href="https://www.digikey.com/product-detail/en/everlight-electronics-co-ltd/PT15-21B-TR8/1080-1379-1-ND"><b>Phototransistor IR</b></a> sensor is a three-layer semiconductor device which has a light-sensitive base region. The base senses the IR and converts it into the current which flows between the collector and the emitter region.</p>
<li><b>Connection and schematic</b></li>
<p>In this case, being a component without a module, I create my own. I design and manufacture a small board where I solder the Phototransistor IR sensor, a 10K resistor, a <a href="https://www.digikey.es/product-detail/es/everlight-electronics-co-ltd/IR15-21C-TR8/1080-1352-1-ND/2676086"><b>IR LED,</b></a> a 1K resistor and with the flat connectors where there is no room for mistakes when connecting it. I use the analog input of the ATtiny1614 PA4 (Arduino pin 0).</p>
<span class="image main"><img src="images/adrianino/a_22.jpg" alt="" /></span>
<p>Here you can find the design in Eagle and the PNG's to create the board.</p>
<p><a href="assignments/adrianino/phototransisor_IR_eagle.zip"><b>- Phototransistor IR Schematic + Board</b></a>
<p><a href="assignments/adrianino/photo_ir_png.zip"><b>- Phototransistor IR traces</b></a></p>
<p><img src="images/adrianino/a_23.jpg" width="70%"; max-width="700" /></p>
<li><b>Programming</b></li>
<p>Here you will find the programming to use an analog sensor such as the Phototransistor sensor. Here you can find the Arduino and Processing files to download.</p>
<p><a href="assignments/adrianino/Hello_Reflect_IR/Hello_Reflect_IR.ino"><b>- Arduino Hello Phototransistor IR sensor</b></a>
<p><a href="assignments/adrianino/photo_ir_processing/photo_ir_processing.pde"><b>- Processing Hello Phototransistor IR sensor</b></a></p>
<pre><code>/******************************************************************************
QRD1114_Proximity_Example.ino
Example sketch for SparkFun's QRD1114 Reflectance Proximity Sensor
(https://www.sparkfun.com/products/246)
Jim Lindblom @ SparkFun Electronics
May 2, 2016
Modified by Adrián Torres Omaña
Phototransistor IR
Adrianino
ATtiny1614
******************************************************************************/
const int Sensor = 0; // Sensor output voltage
void setup()
{
Serial.begin(115200);
pinMode(Sensor, INPUT);
}
void loop()
{
// Read in the ADC and convert it to a voltage:
int proximityADC = analogRead(Sensor);
float proximityV = (float)proximityADC * 5.0 / 1023.0;
Serial.println(proximityV);
delay(100);
}</code></pre>
<p><video controls width="100%"; max-width="800"><source src="images/adrianino/photo_ir.mp4" type="video/mp4"></video></p>
<h1><a id="outputs"></a>Outputs</h1>
<h2><a id="lcd"></a>LCD - I2C</h2>
......
/******************************************************************************
QRD1114_Proximity_Example.ino
Example sketch for SparkFun's QRD1114 Reflectance Proximity Sensor
(https://www.sparkfun.com/products/246)
Jim Lindblom @ SparkFun Electronics
May 2, 2016
Modified by Adrián Torres Omaña
Phototransistor IR
Adrianino
ATtiny1614
******************************************************************************/
const int Sensor = 0; // Sensor output voltage
void setup()
{
Serial.begin(115200);
pinMode(Sensor, INPUT);
}
void loop()
{
// Read in the ADC and convert it to a voltage:
int proximityADC = analogRead(Sensor);
float proximityV = (float)proximityADC * 5.0 / 1023.0;
Serial.println(proximityV);
delay(100);
}
File added
import processing.serial.*;
float sensorValue; //variable for the serial data
Serial myPort;
void setup() { //as dynamic/setup function called initially, only once
size(500, 200);// is the window (1024=sensor max. value)
myPort = new Serial(this, "COM4", 115200); // serial port
background(255); //set background white
}
void draw() { //draw function loops
noStroke(); // outline
fill(255,0,0,20); // color inside
rect(0, 0, sensorValue, height); //position and size
fill(255,70);
rect(sensorValue, 0, width-sensorValue, height);
println(sensorValue);
fill(0,0,0);// these are the colors inside
text(sensorValue + " " + "light" , sensorValue, height/2);
textSize(32);
}
void serialEvent(Serial myPort) { // sketch read the serial data
String inString = myPort.readStringUntil('\n');
if (inString != null) {
inString = trim(inString);
float[] values = float(split(inString, ","));
if (values.length >=1) {
sensorValue = values[0]; //first value in the list
}
}
}
File added
docs/images/adrianino/a_22.jpg

312 KiB

docs/images/adrianino/a_23.jpg

67.2 KiB

File added
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