Dcspeiser
Published © CC BY-NC-ND

4-Digit Binary Display

I have coded a binary display that can display any number, using a simple API!

BeginnerShowcase (no instructions)852
4-Digit Binary Display

Things used in this project

Story

Read more

Code

_12_10_16 (1).ino

Arduino
Connect LEDs to pins 2, 3, 4, and 5. Run the program and it will display the first 900 or so digits of pi. You can also delete the long list of functions at the bottom and replace it with any number you want. Just make sure to treat each digit of the number as a function.
void setup() {
  // put your setup code here, to run once:
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
}

void reset(int x) {
  delay(x);
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
}

void ze(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  reset(x);
}

void on(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, HIGH);
  reset(x);
}

void tw(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, HIGH);
  digitalWrite(5, LOW);
  reset(x);
}

void th(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, LOW);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  reset(x);
}

void fo(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  reset(x);
}

void fi(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, HIGH);
  digitalWrite(4, LOW);
  digitalWrite(5, HIGH);
  reset(x);
}

void si(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, LOW);
  reset(x);
}

void se(int x) {
  digitalWrite(2, LOW);
  digitalWrite(3, HIGH);
  digitalWrite(4, HIGH);
  digitalWrite(5, HIGH);
  reset(x);
}

void ei(int x) {
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, LOW);
  reset(x);
}

void ni(int x) {
  digitalWrite(2, HIGH);
  digitalWrite(3, LOW);
  digitalWrite(4, LOW);
  digitalWrite(5, HIGH);
  reset(x);
}

void loop() {
  // put your main code here, to run repeatedly:
 th(500); 
 on(500);
 fo(500);
 on(500);
 fi(500);
 ni(500);
 tw(500);
 si(500);
 fi(500);
 th(500);
 fi(500);
 ei(500);
 ni(500);
 se(500);
 ni(500);
 th(500);
 tw(500);
 th(500);
 ei(500);
 fo(500);
 si(500);
 tw(500);
 si(500);
 fo(500);
 th(500);
 th(500);
 ei(500);
 th(500);
 tw(500);
 se(500);
 ni(500);
 fi(500);
 ze(500);
 tw(500);
 ei(500);
 ei(500);
 fo(500);
 on(500);
 ni(500);
 se(500);
 on(500);
 si(500);
 ni(500);
 th(500);
 ni(500);
 ni(500);
 th(500);
 se(500);
 fi(500);
 on(500);
 ze(500);
 fi(500);
 ei(500);
 tw(500);
 ze(500);
 ni(500);
 se(500);
 fo(500);
 ni(500);
 fo(500);
 fo(500);
 fi(500);
 ni(500);
 tw(500);
 th(500);
 ze(500);
 se(500);
 ei(500);
 on(500);
 si(500);
 fo(500);
 ze(500);
 si(500);
 tw(500);
 ei(500);
 si(500);
 tw(500);
 ze(500);
 ei(500);
 ni(500);
 ni(500);
 ei(500);
 si(500);
 tw(500);
 ei(500);
 ze(500);
 th(500);
 fo(500);
 ei(500);
 tw(500);
 fi(500);
 th(500);
 fo(500);
 tw(500);
 on(500);
 on(500);
 se(500);
 ze(500);
 si(500);
 se(500);
 ni(500);
 ei(500);
 tw(500);
 on(500);
 fo(500);
 ei(500);
 ze(500);
 ei(500);
 si(500);
 fi(500);
 on(500);
 th(500);
 tw(500);
 ei(500);
 tw(500);
 th(500);
 ze(500);
 si(500);
 si(500);
 fo(500);
 se(500);
 ze(500);
 ni(500);
 th(500);
 ei(500);
 fo(500);
 fo(500);
 si(500);
 ze(500);
 ni(500);
 fi(500);
 fi(500);
 ze(500);
 fi(500);
 ei(500);
 tw(500);
 tw(500);
 th(500);
 on(500);
 se(500);
 tw(500);
 fi(500);
 th(500);
 fi(500);
 ni(500);
 fo(500);
 ze(500);
 ei(500);
 on(500);
 tw(500);
 ei(500);
 fo(500);
 ei(500);
 on(500);
 on(500);
 on(500);
 se(500);
 fo(500);
 fi(500);
 ze(500);
 tw(500);
 ei(500);
 fo(500);
 on(500);
 ze(500);
 tw(500);
 se(500);
 ze(500);
 on(500);
 ni(500);
 th(500);
 ei(500);
 fi(500);
 tw(500);
 on(500);
 on(500);
 ze(500);
 fi(500);
 fi(500);
 fi(500);
 ni(500);
 si(500);
 fo(500);
 fo(500);
 si(500);
 tw(500);
 tw(500);
 ni(500);
 fo(500);
 ei(500);
 ni(500);
 fi(500);
 fo(500);
 ni(500);
 th(500);
 ze(500);
 th(500);
 ei(500);
 on(500);
 ni(500);
 si(500);
 fo(500);
 fo(500);
 tw(500);
 ei(500);
 ei(500);
 on(500);
 ze(500);
 ni(500);
 se(500);
 fi(500);
 si(500);
 si(500);
 fi(500);
 ni(500);
 th(500);
 th(500);
 fo(500);
 fo(500);
 si(500);
 on(500);
 tw(500);
 ei(500);
 fo(500);
 se(500);
 fi(500);
 si(500);
 fo(500);
 ei(500);
 tw(500);
 th(500);
 th(500);
 se(500);
 ei(500);
 si(500);
 se(500);
 ei(500);
 th(500);
 on(500);
 si(500);
 fi(500);
 tw(500);
 se(500);
 on(500);
 tw(500);
 ze(500);
 on(500);
 ni(500);
 ze(500);
 ni(500);
 on(500);
 fo(500);
 fi(500);
 si(500);
 fo(500);
 ei(500);
 fi(500);
 si(500);
 si(500);
 ni(500);
 tw(500);
 th(500);
 fo(500);
 si(500);
 ze(500);
 th(500);
 fo(500);
 ei(500);
 si(500);
 on(500);
 ze(500);
 fo(500);
 fi(500);
 fo(500);
 th(500);
 tw(500);
 si(500);
 si(500);
 fo(500);
 ei(500);
 tw(500);
 on(500);
 th(500);
 th(500);
 ni(500);
 th(500);
 si(500);
 ze(500);
 se(500);
 tw(500);
 si(500);
 ze(500);
 tw(500);
 fo(500);
 ni(500);
 on(500);
 fo(500);
 on(500);
 tw(500);
 se(500);
 th(500);
 se(500);
 tw(500);
 fo(500);
 fi(500);
 ei(500);
 se(500);
 ze(500);
 ze(500);
 si(500);
 si(500);
 ze(500);
 si(500);
 th(500);
 on(500);
 fi(500);
 fi(500);
 ei(500);
 ei(500);
 on(500);
 se(500);
 fo(500);
 ei(500);
 ei(500);
 on(500);
 fi(500);
 tw(500);
 ze(500);
 ni(500);
 tw(500);
 ze(500);
 ni(500);
 si(500);
 tw(500);
 ei(500);
 tw(500);
 ni(500);
 tw(500);
 fi(500);
 fo(500);
 ze(500);
 ni(500);
 on(500);
 se(500);
 on(500);
 fi(500);
 th(500);
 si(500);
 fo(500);
 th(500);
 si(500);
 se(500);
 ei(500);
 ni(500);
 tw(500);
 fi(500);
 ni(500);
 ze(500);
 th(500);
 si(500);
 ze(500);
 ze(500);
 on(500);
 on(500);
 th(500);
 th(500);
 ze(500);
 fi(500);
 th(500);
 ze(500);
 fi(500);
 fo(500);
 ei(500);
 ei(500);
 tw(500);
 ze(500);
 fo(500);
 si(500);
 si(500);
 fi(500);
 tw(500);
 on(500);
 th(500);
 ei(500);
 fo(500);
 on(500);
 fo(500);
 si(500);
 ni(500);
 fi(500);
 on(500);
 ni(500);
 fo(500);
 on(500);
 fi(500);
 on(500);
 on(500);
 si(500);
 ze(500);
 ni(500);
 fo(500);
 th(500);
 th(500);
 ze(500);
 fi(500);
 se(500);
 tw(500);
 se(500);
 ze(500);
 th(500);
 si(500);
 fi(500);
 se(500);
 fi(500);
 ni(500);
 fi(500);
 ni(500);
 on(500);
 ni(500);
 fi(500);
 th(500);
 ze(500);
 ni(500);
 tw(500);
 on(500);
 ei(500);
 si(500);
 on(500);
 on(500);
 se(500);
 th(500);
 ei(500);
 on(500);
 ni(500);
 th(500);
 tw(500);
 si(500);
 on(500);
 on(500);
 se(500);
 ni(500);
 th(500);
 on(500);
 ze(500);
 fi(500);
 on(500);
 on(500);
 ei(500);
 fi(500);
 fo(500);
 ei(500);
 ze(500);
 se(500);
 fo(500);
 fo(500);
 si(500);
 tw(500);
 th(500);
 se(500);
 ni(500);
 ni(500);
 si(500);
 tw(500);
 se(500);
 fo(500);
 ni(500);
 fi(500);
 si(500);
 se(500);
 th(500);
 fi(500);
 on(500);
 ei(500);
 ei(500);
 fi(500);
 se(500);
 fi(500);
 tw(500);
 se(500);
 tw(500);
 fo(500);
 ei(500);
 ni(500);
 on(500);
 tw(500);
 tw(500);
 se(500);
 ni(500);
 th(500);
 ei(500);
 on(500);
 ei(500);
 th(500);
 ze(500);
 on(500);
 on(500);
 ni(500);
 fo(500);
 ni(500);
 on(500);
 tw(500);
 ni(500);
 ei(500);
 th(500);
 th(500);
 si(500);
 se(500);
 th(500);
 th(500);
 si(500);
 tw(500);
 fo(500);
 fo(500);
 ze(500);
 si(500);
 fi(500);
 si(500);
 si(500);
 fo(500);
 th(500);
 ze(500);
 ei(500);
 si(500);
 ze(500);
 tw(500);
 on(500);
 th(500);
 ni(500);
 fo(500);
 ni(500);
 fo(500);
 si(500);
 th(500);
 ni(500);
 fi(500);
 tw(500);
 tw(500);
 fo(500);
 se(500);
 th(500);
 se(500);
 on(500);
 ni(500);
 ze(500);
 se(500);
 ze(500);
 tw(500);
 on(500);
 se(500);
 ni(500);
 ei(500);
 si(500);
 ze(500);
 ni(500);
 fo(500);
 th(500);
 se(500);
 ze(500);
 tw(500);
 se(500);
 se(500);
 ze(500);
 fi(500);
 th(500);
 ni(500);
 tw(500);
 on(500);
 se(500);
 on(500);
 se(500);
 si(500);
 tw(500);
 ni(500);
 th(500);
 on(500);
 se(500);
 si(500);
 se(500);
 fi(500);
 tw(500);
 th(500);
 ei(500);
 fo(500);
 si(500);
 se(500);
 fo(500);
 ei(500);
 on(500);
 ei(500);
 fo(500);
 si(500);
 se(500);
 si(500);
 si(500);
 ni(500);
 fo(500);
 ze(500);
 fi(500);
 on(500);
 th(500);
 tw(500);
 ze(500);
 ze(500);
 ze(500);
 fi(500);
 si(500);
 ei(500);
 on(500);
 tw(500);
 se(500);
 on(500);
 fo(500);
 fi(500);
 tw(500);
 si(500);
 th(500);
 fi(500);
 si(500);
 ze(500);
 ei(500);
 tw(500);
 se(500);
 se(500);
 ei(500);
 fi(500);
 se(500);
 se(500);
 on(500);
 th(500);
 fo(500);
 tw(500);
 se(500);
 fi(500);
 se(500);
 se(500);
 ei(500);
 ni(500);
 si(500);
 ze(500);
 ni(500);
 on(500);
 se(500);
 th(500);
 si(500);
 th(500);
 se(500);
 on(500);
 se(500);
 ei(500);
 se(500);
 tw(500);
 on(500);
 fo(500);
 si(500);
 ei(500);
 fo(500);
 fo(500);
 ze(500);
 ni(500);
 ze(500);
 on(500);
 tw(500);
 tw(500);
 fo(500);
 ni(500);
 fi(500);
 th(500);
 fo(500);
 th(500);
 ze(500);
 on(500);
 fo(500);
 si(500);
 fi(500);
 fo(500);
 ni(500);
 fi(500);
 ei(500);
 fi(500);
 th(500);
 se(500);
 on(500);
 ze(500);
 fi(500);
 ze(500);
 se(500);
 ni(500);
 tw(500);
 tw(500);
 se(500);
 ni(500);
 si(500);
 ei(500);
 ni(500);
 tw(500);
 fi(500);
 ei(500);
 ni(500);
 tw(500);
 th(500);
 fi(500);
 fo(500);
 tw(500);
 ze(500);
 on(500);
 ni(500);
 ni(500);
 fi(500);
 si(500);
 on(500);
 on(500);
 tw(500);
 on(500);
 tw(500);
 ni(500);
 ze(500);
 tw(500);
 on(500);
 ni(500);
 si(500);
 ze(500);
 ei(500);
 si(500);
 fo(500);
 ze(500);
 th(500);
 fo(500);
 fo(500);
 on(500);
 ei(500);
 on(500);
 fi(500);
 ni(500);
 ei(500);
 on(500);
 th(500);
 si(500);
 tw(500);
 ni(500);
 se(500);
 se(500);
 fo(500);
 se(500);
 se(500);
 on(500);
 th(500);
 ze(500);
 ni(500);
 ni(500);
 si(500);
 ze(500);
 fi(500);
 on(500);
 ei(500);
 se(500);
 ze(500);
 se(500);
 tw(500);
 on(500);
 on(500);
 th(500);
 fo(500);
 ni(500);
 ni(500);
 ni(500);
 ni(500);
 ni(500);
 ni(500);
 ei(500);
 th(500);
 se(500);
 tw(500);
 ni(500);
 se(500);
 ei(500);
 ze(500);
 fo(500);
 ni(500);
 ni(500);
 fi(500);
 on(500);
 ze(500);
 fi(500);
 ni(500);
 se(500);
 th(500);
 on(500);
 se(500);
 th(500);
 tw(500);
 ei(500);
 on(500);
 si(500);
 ze(500);
 ni(500);
 si(500);
 th(500);
 on(500);
 ei(500);
 fi(500);
 ni(500);
 fi(500);
 ze(500);
 tw(500);
 fo(500);
 fo(500);
 fi(500);
 ni(500);
 fo(500);
 fi(500);
 fi(500);
 th(500);
 fo(500);
 si(500);
 ni(500);
 ze(500);
 ei(500);
 th(500);
 ze(500);
 tw(500);
 si(500);
 fo(500);
 tw(500);
 fi(500);
 tw(500);
 tw(500);
 th(500);
 ze(500);
 ei(500);
 tw(500);
 fi(500);
 th(500);
 th(500);
 fo(500);
 fo(500);
 si(500);
 ei(500);
 fi(500);
 ze(500);
 th(500);
 fi(500);
 tw(500);
 si(500);
 on(500);
 ni(500);
 th(500);
 on(500);
 on(500);
 ei(500);
 ei(500);
 on(500);
 se(500);
 on(500);
 ze(500);
 on(500);
 ze(500);
 ze(500);
 ze(500);
 th(500);
 on(500);
 th(500);
 se(500);
 ei(500);
 th(500);
 ei(500);
 se(500);
 fi(500);
 tw(500);
 ei(500);
 ei(500);
 si(500);
 fi(500);
 ei(500);
 se(500);
 fi(500);
 th(500);
 th(500);
 tw(500);
 ze(500);
 ei(500);
 th(500);
 ei(500);
 on(500);
 fo(500);
 tw(500);
 ze(500);
 si(500);
 on(500);
 se(500);
 on(500);
 se(500);
 se(500);
 si(500);
 si(500);
 ni(500);
 on(500);
 fo(500);
 se(500);
 th(500);
 ze(500);
 th(500);
 fi(500);
...

This file has been truncated, please download it to see its full contents.

Credits

Dcspeiser
1 project • 0 followers

Comments