Pages

arduino reset

u could connect an IO pin X to the reset pin via a 1kR resistor...
if that IO pin X is INPUT/LOW no reset is triggered (like the reset button is unpressed)...
if that IO pin X is OUTPUT/LOW a reset is triggered (like the reset button is pressed)...


 //digitalPin 7 is connected to the RESET pin on Arduino
//NOTE: you CANNOT program the board while they are connected
//by default digitalPin 13 will blink upon reset, so stick an LED in there

int interval = 5000;
long int time = 0;

void setup(){
  digitalWrite(7, HIGH); //We need to set it HIGH immediately on boot
  pinMode(7,OUTPUT);     //We can declare it an output ONLY AFTER it's HIGH
                         // (( HACKHACKHACKHACK ))
  Serial.begin(9600);    //So you can watch the time printed
}


void loop(){

  time = millis();
 
  Serial.println(time);
 
  if(time > interval){
    Serial.println("RESET!");
    digitalWrite(7, LOW); //Pulling the RESET pin LOW triggers the reset.
  }
}

0 意見:

張貼留言

 

Copyright © 阿杰老師的 Arduino 實驗室. Template created by Volverene from Templates Block
WP by Simply WP | Solitaire Online