Nilton Anchayhua Fab Academy 2015
Home
Assignments
Final project
About me
Week 1 - Principles and practices, project management Week 2 - Computer aided design Week 3 - Computer controlled cutting Week 4 - Electronics production Week 5 - 3d scanning and printing Week 6 - Electronics design Week 7 - Embedded programming Week 8 - Computer controlled machining Week 9 - Molding and casting Week 11 - Input devices Week 12 - Output devices Week 13 - Composites Week 14 - Networking and communications Week 15 - Interface and application programming Week 16 - Applictions and implications Week 17 - Mechanical design - machine design Week 18 - Invention, intellectual property and income Week 19 - project development

OUTPUT DEVICES

Was a great experience did this assignment, so I learned how can i command the output device, the led array is fabolous,with 5 pins I can control 20 leds.
I made a modification in the program, introducing my name. like I show you below.
                #include 
#include 

#define output(directions,pin) (directions |= pin) // set port direction for output
#define input(directions,pin) (directions &= (~pin)) // set port direction for input 
#define set(port,pin) (port |= pin) // set port pin
#define clear(port,pin) (port &= (~pin)) // clear port pin
#define pin_test(pins,pin) (pins & pin) // test for port pin
#define bit_test(byte,bit) (byte & (1 << bit)) // test for bit set

#define led_delay() _delay_ms(1) // LED delay


#define led_port PORTA
#define led_direction DDRA

#define A (1 << PA1) // row 1
#define B (1 << PA2) // row 2
#define C (1 << PA3) // row 3
#define D (1 << PA4) // row 4
#define E (1 << PA5) // row 5

void flash(uint8_t from, uint8_t to, uint8_t delay) {
   //
   // source from, sink to, flash
   //
   static uint8_t i;
   set(led_port,from);
   clear(led_port,to);
   output(led_direction,from);
   output(led_direction,to);
   for (i = 0; i < delay; ++i)
       led_delay();
   input(led_direction,from);
   input(led_direction,to);
   }
I had to modified the function and I added one argument to choose a letter    
void led_cycle(uint8_t number, uint8_t delay, char m) {
   //
   // cycle through LEDs
   //
   uint8_t i;
   for (i = 0; i < number; ++i) {
      

// N   

N

if(m == 'N') { flash(B,A,delay); flash(C,A,delay); flash(D,A,delay); flash(E,A,delay); flash(E,B,delay); flash(D,C,delay); flash(B,D,delay); flash(A,E,delay); flash(B,E,delay); flash(C,E,delay); flash(D,E,delay); } // I

I

if(m == 'I'){ flash(E,A,delay); flash(E,B,delay); flash(E,C,delay); flash(E,D,delay); flash(D,E,delay); flash(D,C,delay); flash(B,C,delay); flash(A,C,delay); flash(B,A,delay); flash(A,B,delay); flash(A,D,delay); flash(A,E,delay); } // L

L

if(m=='L'){ flash(E,A,delay); flash(D,A,delay); flash(C,A,delay); flash(B,A,delay); flash(A,B,delay); flash(A,C,delay); flash(A,D,delay); flash(A,E,delay); } // T

T

if(m=='T'){ flash(E,A,delay); flash(E,B,delay); flash(E,C,delay); flash(E,D,delay); flash(D,E,delay); flash(D,C,delay); flash(B,C,delay); flash(A,C,delay); } // O

O

if(m=='O'){ flash(E,A,delay); flash(D,A,delay); flash(C,A,delay); flash(B,A,delay); flash(A,E,delay); flash(B,E,delay); flash(C,E,delay); flash(D,E,delay); flash(E,A,delay); flash(E,B,delay); flash(E,C,delay); flash(E,D,delay); flash(D,E,delay); flash(B,A,delay); flash(A,B,delay); flash(A,C,delay); flash(A,D,delay); flash(A,E,delay); } // N

N

if(m=='N'){ flash(B,A,delay); flash(C,A,delay); flash(D,A,delay); flash(E,A,delay); flash(E,B,delay); flash(D,C,delay); flash(B,D,delay); flash(A,E,delay); flash(B,E,delay); flash(C,E,delay); flash(D,E,delay); } } } int main(void) { // // set clock divider to /1 // CLKPR = (1 << CLKPCE); CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0); // // main loop // while (1) { led_cycle(1,100,'N'); led_cycle(3,20,'N'); led_cycle(100,1,'N'); led_cycle(1,100,'I'); led_cycle(3,20,'I'); led_cycle(100,1,'I'); led_cycle(1,100,'L'); led_cycle(3,20,'L'); led_cycle(100,1,'L'); led_cycle(1,100,'T'); led_cycle(3,20,'T'); led_cycle(100,1,'T'); led_cycle(1,100,'O'); led_cycle(3,20,'O'); led_cycle(100,1,'O'); led_cycle(1,100,'N'); led_cycle(3,20,'N'); led_cycle(100,1,'N'); led_cycle(100,1,'N'); led_cycle(100,1,'I'); led_cycle(100,1,'L'); led_cycle(100,1,'T'); led_cycle(100,1,'O'); led_cycle(100,1,'N'); } }
I made the laser led activate, in this stage I bought the laser led and I implemented with the fabduino.
I programmed a simple program to activate the laser led, as show below:

#define led_port PORTB
#define led_direction DDRB
#define led_pin (1 << PB5)

int delay10s(void){ delay of 10 seconds
  
  ;i++)
  {
    led_delay2();
  } 
}

int main(void) {
   //
   // main
   //
   // set clock divider to /1
   //
   CLKPR = (1 << CLKPCE);
   CLKPR = (0 << CLKPS3) | (0 << CLKPS2) | (0 << CLKPS1) | (0 << CLKPS0);
   //
   // initialize LED pin
   //
   clear(led_port, led_pin);
   output(led_direction, led_pin);
   //
   // main loop
   //
   while (1) {
     delay10s();
      set(led_port, led_pin);
      led_delay();
      clear(led_port, led_pin);
      led_delay();
      set(led_port, led_pin);
      led_delay();
      clear(led_port, led_pin);
      led_delay();
      }
   }
I made the hello LCD too, but unhappily It didn't work, I think the problem was in the stage soldered, until this moment I had problems with many boards,I think the problem was in the stage soldered, until this moment I had problems with many pcb maybe the electrical load on my hand or the high temperature on the solder.
You can download the archives from here