UPDATE : OBJETIVES
The objective of this assignment is to add a sensor that introduces analog data in the processor and can read them producing a signal that activates a led
UPDATE : LEVEL PROCEDURE USING MULTIMETER
connect one of the plugs of the polymeter to the milling tool and the other to the copper plate to be milled.
set the polimetro in the line review mode with sound.
fix any z feature without touching the copper plate.
to descend the
tool with maximum care and precision in different points of the copper plate, obtaining by difference with z characteristic the different z of the points of the plate with the precision of the engraving machine
//call to include a library for serial comunication
#include "SoftwareSerial.h"
// variables declaration
const int analogInPin = A2; // Analog input pin that the potentiometer is attached to
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
const int Rx = 1; // this is physical pin 7
const int Tx = 2; // this is physical pin 6
SoftwareSerial mySerial(Rx, Tx);
// In this block of code the communication modes of each pin (in or out) are established and the serial console is initialized
void setup() {
pinMode(3, OUTPUT);
pinMode(Rx, INPUT);
pinMode(Tx, OUTPUT);
mySerial.begin(115200); // send serial data at 115200 bits/sec
}
now what is intended is that the ldr sensor send analog values to the processor
These are read through the analogInPin port.
but these values will be contained in a range between 0 and 1023
therefore we map these values between
0 and 255 and store it in the variable outputValue
later we show it in console with the string "sensor value ="
finally we establish the conditions in which the led will light
if the mapped value exceeds 240 the LED goes out, and
in all other values it will remain on
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 1023, 0, 255);
mySerial.print("sensorValue
= ");
mySerial.println(outputValue);
if(outputValue > 240){
digitalWrite(3, LOW);
}else {
digitalWrite(3, HIGH);
}
delay(10);
}