week11 update

parent 973f541d
Pipeline #89007 passed with stage
in 18 seconds
......@@ -106,6 +106,13 @@
<h6>Source: https://randomnerdtutorials.com/complete-guide-for-ultrasonic-sensor-hc-sr04/</h6>
The choice of these sensors is aligned with my final project, since I have to measure the water temperature of the steaming machine and the amount of water that exists in the tank with the presence sensor.<br>
<br><h2>Analog Digital Converter (ADC)</h2>
The ADC contains a Sample and Hold circuit which ensures that the input voltage to the ADC is
held at a constant level during conversion.
<a title="ADC Diagram"><img class="image center" src="images/week11/adc.jpg"></a>
The ADC converts an analog input voltage to a 10-bit digital value through successive approximation. The minimum value represents GND and the maximum value represents the reference voltage.
These values ​​are within the microcontroller ranging from 0 to 1023, representing 0V and 5V respectively.<br>
<br><h2>Board</h2>
As described above, I have decided to use an analog and a digital sensor, as I will use these sensors for my final project. Therefore, I reread the attiny44's datasheet to know how to use the analog and digital input pins.<br>
The attiny44 has a total of 7 analog pins, internally it has a digital analog converter (ADC) which will help us to interpret the analog sensor in a better way.<br>
......@@ -130,11 +137,61 @@
The first test is the distance sensor, I work with these one several times, for that reason it was the first one.
In my board I did not use a led for output, so I only use the software serial monitor to see my distance.
<a title="Distance code"><img class="image center" src="images/week11/distance.jpg"></a>
Here is the code.
<pre><code>#include <SoftwareSerial.h>
SoftwareSerial monserial(0, 1);
long distancia;
long tiempo;
int trigger=10;
int echo=9;
void setup() {
// put your setup code here, to run once:
monserial.begin(9600);
pinMode(trigger, OUTPUT);
pinMode(echo, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigger,LOW);
delayMicroseconds(5);
digitalWrite(trigger,HIGH);
delayMicroseconds(10);
tiempo=pulseIn(echo,HIGH);
distancia= int(0.0175*tiempo);
monserial.println("Distance ");
monserial.println(distancia);
monserial.println(" cm");
delay(500);
}</code></pre>
<br><h4>Thermistor</h4>
For this case, I use<a href="https://learn.adafruit.com/thermistor/using-a-thermistor"> this tutorial</a> to programming my temperature sensor. These was the formula:
<pre><code>reading = (1023.0 / value) - 2.0;
temp = reading*100.0;</code></pre>
<a title="Temperature code"><img class="image center" src="images/week11/temperature.jpg"></a>
Here is the code:
<pre><code>#include <SoftwareSerial.h>
SoftwareSerial monserial(0, 1);
int ther=A2;
float temp;
float value;
float reading;
void setup() {
pinMode(ther,INPUT);
monserial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
value=analogRead(ther);
reading = (1023.0 / value) - 2.0;
temp = reading*100.0;
monserial.print("Temperature ");
monserial.println(temp);
delay(1000);
} </pre></code>
<br><h4>Both sensors</h4>
I try to make an only program, but I have a critical problem. The software serial library uses a lot of the internal memory, my programs are too heavy for the attiny44.
<a title="Memory problem"><img class="image center" src="images/week11/fullmemory.jpg"></a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment