Seeing initial pin output in AutoIT


I've "inherited" a job at work where we are using an Arduino Nano with a relay to bring on a beacon, using a really simple AutoIT script.

All the script does is literally turn a beacon on and off, depending if there is some text in a window or not.

The problem I'm having is that at the start of the script, I'd like it to know what state the beacon is in - off or on. I thought that would be simple, and it may well be for someone who hadn't just seen an Arduino for the first time four days ago :slight_smile:

Anyway, here's my (very very basic script):

int led = 12;
void setup() {
  // put your setup code here, to run once:
  pinMode(led, OUTPUT);

void loop() {
  // put your main code here, to run repeatedly:
    int data =;
    if (data == '0') //Off
      digitalWrite(led, LOW);
      Serial.print("Beacon off");
    if (data == '1') //On
      digitalWrite(led, HIGH);
      Serial.print("Beacon on");

When I run AutoIT, I'd like it to tell me the beacon's initial state straight away, just once. If I turn the beacon on I can see "Beacon on" in the console, and if I turn it off I can see "Beacon off", so that bit works perfectly. But I'd like the console to detect the state of pin 12 and report that before I turn it off or on.

I've tried putting digitalRead(led) in various parts of the script, but I only ever see a blank line in AutoIT's console.

Where am I going wrong?!



This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.