• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Electronic Brick AD Key Module Code

Mechduino

New Member
Hello,
I am attempting to read the output from an Electronic Brick AD Key Module, but all the code I have seen does not help at all, so anyway, any help would be appreciated, as is obvious I am new to coding Arduinos so don't judge me please XD
Thanks.
 

Sceadwian

Banned
A clue to what you're talking about including links and code reference might help.

I had to Google to find this link.

The output from that modules is a ratio metric analog voltage based on the main voltage, subject to noise, but you'd need to feed that into the ADC of an Arduino to read it and you've had to be sure the noise was low enough and the ADC was within the range.
 

be80be

Well-Known Member
That thing is easy as pie to use I'll post you a test code here in a min.

I don't have a brick but this should work with little changes to Button_Min and Button_Max
You put power to the thing and read the high and low value to set them

Code:
const int Button_Min = 100;      // Button minimum, discovered through experiment
const int Button_Max = 1023;    // Button maximum, discovered through experiment

void setup() {
  // initialize serial communication:
  Serial.begin(9600);  
}

void loop() {
  // read the Button
  int Buttons_read = analogRead(A0);
  // map the Button range to a range of five options:
  int Button = map(Buttons_read, Button_Min, Button_Max, 0, 4);

  // do something different depending on the 
  // Button value:
  switch (Button) {
  case 0:    // your hand is on the Button
    Serial.println("button1");
    break;
  case 1:    // your hand is close to the Button
    Serial.println("button2");
    break;
  case 2:    // your hand is a few inches from the Button
    Serial.println("button3");
    break;
  case 3:    // your hand is nowhere near the Button
    Serial.println("button4");
    break;
    case 4:    // your hand is nowhere near the Button
    Serial.println("button5");
    break;
  } 

}
 
Last edited:

be80be

Well-Known Member
I took the time to draw out how that brick is wired up. If you hook the brick up and take a reading from Ground to the adc output to find the highest reading use that for Button_Max'

Then find the lowest reading button use that in Button_Min

The Button_Min should be like 178 and the Button_max should be 1023

You'll figure it like this reading lowest 204.6x.87 rounded to 178

your high reading is say 204.6x5 = 1023

But you need to test them to find the settings
 

Latest threads

EE World Online Articles

Loading

 
Top