Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created May 3, 2023 16:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmarr58/e191f145dd208bf5db78d9cd0b193a8e to your computer and use it in GitHub Desktop.
Save esmarr58/e191f145dd208bf5db78d9cd0b193a8e to your computer and use it in GitHub Desktop.
#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