COPERNICON
Published © GPL3+

Controlling the LEGO interface A with arduino

A short project in how to use the LEGO interface A with an arduino pro micro

BeginnerWork in progress88
Controlling the LEGO interface A with arduino

Things used in this project

Hardware components

lego interface A
×1
appropriate power supply
7 to 15 VAC or 12 to 24VDC, min 11VA!
×1
LEGO 4.5v cables, motors and sensors
×1
arduino pro micro
×1
adafruit IDC cable to breadboard adapter
note, the adaptor sits very loosely on the breadboard
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

example arduino code for the interface A

C/C++
// i/O of the interA
const int input6= 15;
const int input7= 16;
const int output0= 3;
const int output1= 5;
const int output2= 6;
const int output3= 9;
const int output4= 10;
const int output5= 14;

int I6state = 0;
int I7state = 0;

const int P1 = A0;
float potmeter = 0; 

void setup() {
  // put your setup code here, to run once:
  pinMode(input6, INPUT);
  pinMode(input7, INPUT);
  pinMode(output0, OUTPUT);
  pinMode(output1, OUTPUT);
  pinMode(output2, OUTPUT);
  pinMode(output3, OUTPUT);
  pinMode(output4, OUTPUT);
  pinMode(output5, OUTPUT);

  Serial.begin(9600);
}

void loop() {
  I6state = digitalRead(input6);

    if (I6state == HIGH) {
      analogtest();
      Serial.println("HIGH");
  } else {
      Serial.println("LOW");
      analogWrite(output0,0);
 
  }
  delay(10);
}

void analogtest() {
  potmeter = map(analogRead(P1), 0, 1000, 5, 250);
  Serial.println(potmeter);
  analogWrite(output0,potmeter);
  delay(10); 
}

Credits

COPERNICON
3 projects • 1 follower

Comments