Created
May 3, 2023 16:05
-
-
Save esmarr58/e191f145dd208bf5db78d9cd0b193a8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define sensorTemperatura A0 | |
#define nSLEEP 8 | |
#define STEP 9 | |
#define DIR 10 | |
#define NENBL 11 | |
#define M1 12 | |
volatile double voltajeSensor = 0; | |
volatile uint16_t paso = 0; | |
volatile long int numeroPasos = 0; | |
long int tiempo0 = 0; | |
long int tiempo1 = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
pinMode(nSLEEP, OUTPUT); | |
pinMode(STEP, OUTPUT); | |
pinMode(DIR, OUTPUT); | |
pinMode(NENBL, OUTPUT); | |
pinMode(M1, OUTPUT); | |
delay(10); | |
digitalWrite(nSLEEP, HIGH); //Activar el modulo | |
digitalWrite(NENBL, LOW); | |
digitalWrite(M1, HIGH); | |
Serial.begin(115200); | |
tiempo1 = millis(); | |
} | |
void loop() { | |
//while(1); | |
// put your main code here, to run repeatedly: | |
digitalWrite(STEP, HIGH); | |
delayMicroseconds(2); | |
digitalWrite(STEP, LOW); | |
delayMicroseconds(2); | |
voltajeSensor = analogRead(sensorTemperatura); | |
tiempo0 = millis(); | |
if(tiempo0 > (1000+tiempo1)){ | |
tiempo1 = millis(); | |
voltajeSensor = analogRead(sensorTemperatura); | |
voltajeSensor = 5*voltajeSensor/1024-0.5; | |
voltajeSensor = voltajeSensor/0.01; | |
Serial.println(voltajeSensor); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment