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

update_input_samdino

parent 69061852
No related branches found
No related tags found
Loading
Pipeline #201855 passed
//Fab Academy 2020 - Fab Lab León
//NTC sensor
//SAMDino
//SAMD11C
int sensorPin = 4; // analog input pin to hook the sensor to
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(115200); // initialize serial communications
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
sensorValue = map(sensorValue, 0, 85, 0, 40);
Serial.println(sensorValue); // print value to Serial Monitor
//mySerial.println("x"); // print value "x" to Serial Monitor
delay(500); // short delay so we can actually see the numbers
}
//Fab Academy 2020 - Fab Lab León
//Phototransistor
//SAMDino
//SAMD11C
int sensorPin = 4; // analog input pin to hook the sensor to
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(115200); // initialize serial communications
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
sensorValue = map(sensorValue, 25, 50, 0, 1024);
Serial.println(sensorValue); // print value to Serial Monitor
//mySerial.println("x"); // print value "x" to Serial Monitor
delay(500); // short delay so we can actually see the numbers
}
//Fab Academy 2020 - Fab Lab León
//Phototransistor IR
//SAMDino
//SAMD11C
int sensorPin = 4; // analog input pin to hook the sensor to
int sensorValue = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(115200); // initialize serial communications
}
void loop() {
sensorValue = analogRead(sensorPin); // read the value from the sensor
sensorValue = map(sensorValue, 40, 60, 0, 1024);
Serial.println(sensorValue); // print value to Serial Monitor
//mySerial.println("x"); // print value "x" to Serial Monitor
delay(500); // short delay so we can actually see the numbers
}
//Fab Academy 2020 - Fab Lab León
//Ultrasonic sensor
//SAMDino
//SAMD11C
const int EchoPin = 4;
const int TriggerPin = 5;
void setup() {
Serial.begin(115200);
pinMode(TriggerPin, OUTPUT);
pinMode(EchoPin, INPUT);
}
void loop() {
int cm = ping(TriggerPin, EchoPin);
Serial.print("");
Serial.println(cm);
delay(1000);
}
int ping(int TriggerPin, int EchoPin) {
long duration, distanceCm;
digitalWrite(TriggerPin, LOW); //to generate a clean pulse we set LOW 4us
delayMicroseconds(4);
digitalWrite(TriggerPin, HIGH); //we generate Trigger (trigger) of 10us
delayMicroseconds(10);
digitalWrite(TriggerPin, LOW);
duration = pulseIn(EchoPin, HIGH); //we measure the time between pulses, in microseconds
distanceCm = duration * 10 / 292/ 2; //we convert distance, in cm
return distanceCm;
}
File added
File added
docs/images/samdino/s_23.jpg

275 KiB

docs/images/samdino/s_24.jpg

299 KiB

docs/images/samdino/s_25.jpg

124 KiB

docs/images/samdino/s_26.jpg

299 KiB

File added
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment