ArduinoKoen
Published © GPL3+

Ultra Flat Screen

An ultra flat screen built out of single row of LEDs.

IntermediateShowcase (no instructions)2,827
Ultra Flat Screen

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
3 mm LED: Red
3 mm LED: Red
×12
Photo transistor
×1
Resistor 10k ohm
Resistor 10k ohm
×1
5 mm LED: Red
5 mm LED: Red
×1
Through Hole Resistor, 470 ohm
Through Hole Resistor, 470 ohm
×12
Resistor 220 ohm
Resistor 220 ohm
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Ultra Flat Screen

Mount row of LEDs on a spring. It will produce 2 dimensional pictures.

Ultra Flat Screen Fritzing

Code

Ultra Flat Screen

C/C++
Sends message to row of LEDs mounted on a spring.
void setup() {
  // put your setup code here, to run once:
  DDRB = DDRB | B00111111;
  DDRD = DDRD | B11111100; //set digital ports as output

  PORTB = PORTB | B00111111;
  PORTD = PORTD | B11111100; //put all small LED's to sleep


  pinMode(A1, OUTPUT);   
  digitalWrite(A1,1);  //set A1 to feed position measurement  
  pinMode(A2, OUTPUT);   
  digitalWrite(A2,1);  //switch on LED distance measurement

  pinMode(A0, INPUT);  //set A0 to monitor phototransistor
  
  Serial.begin(9600); //just in case we need this for trouble shooting
  delay(1000);

}

unsigned int nf    [8] = {256*B00000000+B00000000,
                          256*B00111110+B10000100,
                          256*B00100000+B11000100,
                          256*B00100000+B10100100,
                          256*B00111100+B10010100,
                          256*B00100000+B10001100,
                          256*B00100000+B10000100,
                          256*B00000000+B00000000
                         };
                          
unsigned int heart  [8] = {256*B00000000+B00000000,
                           256*B00001110+B11100000,
                           256*B00011111+B11110000,
                           256*B00111111+B11111000,
                           256*B00001111+B11100000,
                           256*B00000011+B10000000,
                           256*B00000001+B00000000,
                           256*B00000000+B00000000
                           };

unsigned int v      [8] = {256*B00000000+B00000000,
                           256*B00100000+B00000100,
                           256*B00010000+B00001000,
                           256*B00001000+B00010000,
                           256*B00000100+B00100000,
                           256*B00000010+B01000000,
                           256*B00000001+B10000000,
                           256*B00000000+B00000000
                           };





void loop() {
  byte curPos = measPos(); //read position
  toScreen(nf[curPos]); //send message as function of current position
  //delay(100);
}


//write message to screen
void toScreen(int msg) {
  PORTB = ~highByte(msg); //LEDs are common anode!!!
  PORTD = ~lowByte(msg);
}

//measure position
byte measPos() {

  unsigned int E = analogRead(A0);  //read phototransistor
  
  //select valid range
  const unsigned int Emax = 800;
  const unsigned int Emin = 600;
 // Serial.println(E);
  if (E <= Emin) return 0; 
  if (E >= Emax) return 0;

  //linearize valid range
  const unsigned int maxInt = 65535; //maximum value in two byte integer (2^16-1)
  const unsigned int recEmax = maxInt/Emax;
  const unsigned int recEmin = maxInt/Emin;
  const byte numPos = 8;
  unsigned int recE = maxInt/E;
  byte measPos = (recE - recEmax) * numPos / (recEmin - recEmax); 
  //measPos = (1.0/E-1.0/Emax)*numPos/(1.0/Emin-1.0/Emax); 

  //Serial.println(measPos);

  return numPos-measPos-1;
}

Credits

ArduinoKoen
0 projects • 6 followers

Comments