Go Down

Topic: Make input high without hardware (Read 206 times) previous topic - next topic

kasperzegel

Hi,

Is there a way to make a input high by software only?
I'm trying to make the interrupt high without the use of any hardware, since the code triggers the interrupt. For now i'm just using the blink sketch. When the first loop is done, the hardware goes to sleep.


Code: [Select]
#define LED_PIN 13
#define INT_OUTPUT 12
#define INT_INPUT 3

#include <Wire.h>
#include <LowPower.h>
#include <VL53L1X.h>

VL53L1X sensor;

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(INT_OUTPUT, OUTPUT);
  pinMode(INT_INPUT, INPUT_PULLUP);
 
  for (int i = 0; i < 20; i++) {
    if(i != 2)
    pinMode(i, OUTPUT);
   
  }
 
  attachInterrupt(0, digitalInterrupt, FALLING); //interrupt for waking up
 
}


void loop() {

  LowPower.powerDown(SLEEP_FOREVER , ADC_OFF, BOD_OFF);

  digitalWrite(LED_PIN, HIGH);
  delay(1000);
  digitalWrite(LED_PIN, LOW);
  delay(1000);
  digitalWrite(0, HIGH);

  if(INT_INPUT == HIGH){
    digitalWrite(LED_PIN, HIGH);
    delay(100);
    digitalWrite(LED_PIN, LOW);
    delay(100);
  }

 
}

void digitalInterrupt(){
  //needed for the digital input interrupt
}



aarg

Look at the differences between that, and the example sketch:
Code: [Select]
// **** INCLUDES *****
#include "LowPower.h"

// Use pin 2 as wake up pin
const int wakeUpPin = 2;

void wakeUp()
{
    // Just a handler for the pin interrupt.
}

void setup()
{
    // Configure wake up pin as input.
    // This will consumes few uA of current.
    pinMode(wakeUpPin, INPUT);   
}

void loop()
{
    // Allow wake up pin to trigger interrupt on low.
    attachInterrupt(0, wakeUp, LOW);
   
    // Enter power down state with ADC and BOD module disabled.
    // Wake up when wake up pin is low.
    LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF);
   
    // Disable external pin interrupt on wake up pin.
    detachInterrupt(0);
   
    // Do something here
    // Example: Read sensor, data logging, data transmission.
}
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

ArnavPawarAA

No way to trigger the interrupt without the hardware. But please tell me why do you want to do that? You need to have the interrupt pin free from any other connection if you want to use interrupts.

..Arnav
Don't ever give up from your projects. Post in the forums, everyone will help you : )

Robin2

No way to trigger the interrupt without the hardware.
That's not true.

If you set one of the interrupt pins as OUTPUT and change it from LOW to HIGH with digitalWrite() (or vice versa) it will trigger the interrupt.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

pcbbc

This is nonsense...
Code: [Select]

#define INT_INPUT 3
if(INT_INPUT == HIGH){

To check a pin state you need to call digitalRead().

Go Up