5 by 40 multi-color LED display with digital/magic LED strips http://www.youtube.com/watch?v=Txduzhp29fQ

Dependencies:   mbed

Revision:
0:a7ec991a632c
Child:
1:77d32b0c953c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 06 18:13:38 2011 +0000
@@ -0,0 +1,1412 @@
+#include "mbed.h"
+
+
+//PwmOut CLK(p21); // pwm als klok, minimale pulsbreedte klok 300ns ofwel 3.33MHz max freq.
+PwmOut fade(p22); // voor faden van leds.
+DigitalOut latch(p19);
+DigitalOut data(p20);
+DigitalOut clk(p18);
+DigitalOut s1(p17);
+DigitalOut s2(p16);
+DigitalOut s3(p15);
+DigitalOut s4(p14);
+DigitalOut s5(p13);
+
+//SPIHalfDuplex master(p5, NC,p7);  
+
+/*
+Bit #     Meaning
+7     Latchable. A 1 here makes the byte latachable, otherwise the byte is considered void and wont latch into the LED.
+6     Double speed fading. See the S pin description. If set  the LED will fade at double speed. Once on S going high and agan when S goes low.
+5     Blue 1
+4     Blue 0
+3     Red 1
+2     Red 0
+1     Green 1
+0     Green 0
+*/
+
+/*Timing specifics:
+LED PWM frequency is 500Hz.
+Clock ON pulse must be > 300nSec.
+Latch should be > 1uSec.
+There is a 100nSec delay between latch into each LED and latch OUT of each LED.
+After setting the datapin, you must wait at least 250nSec for each LED in your strip BEFORE taking clock high. 100 LEDS = 100 x 250nSec delay between sending last bit of data and taking latch high
+*/
+
+DigitalOut myled(LED1);
+
+
+void sendByte(unsigned char it) // decoderen van een byte naar serieel uitsturen
+{
+char x;
+clk=0;
+
+    for(x=0; x<8; x++)
+    {
+        if(128 & it)        data=1;  // 128 om te kijken of de data bedoelt is om te latchen, zo niet wordt er niks uitgestuurd
+        else data=0;
+        it = it<<1;
+        wait_us(0.1); // 250x het aantal leds, dan in ns voor te zorgen dat het signaal wel het einde van de strip bereikt.
+        clk=1;
+        wait_us(0.3); // vereiste pulsbreedte van de clk.
+        clk=0;
+    }    
+
+}
+
+void clear()
+{   
+ int i;
+ for(i=0 ; i < 80 ; i++)// i< het aantal leds op de strip
+        {
+            sendByte(0); 
+        }    
+}
+
+void latchen(){
+
+latch=1;
+wait_us(0.001);
+latch=0;
+}
+
+void send_position(int x){
+int i;
+for(i=0 ; i < x ; i++) // doorschuiven naar positie x
+        {
+            sendByte(0); 
+        }    
+        latchen(); // die plaats aan zetten.
+        clear();
+     
+
+
+}
+
+void erase(){
+int x = 85;
+
+ s1=0;
+       s2=0;
+       s3=0;
+       
+       s4=0;
+       s5=0;
+       
+   for(int i=0 ; i < x ; i++) // alle leds uitzetten
+        {
+            sendByte(128);
+             
+        }
+        latchen();
+       s1=1;
+       s2=1;
+       s3=1;
+       s4=1;
+       s5=1;
+
+}
+
+void move(int x)
+{
+ s1=0;
+       s2=0;
+       s3=0;
+       
+       s4=0;
+       s5=0;
+       
+   for(int i=0 ; i < x ; i++) // alle leds uitzetten
+        {
+            sendByte(128);
+             
+        }
+        latchen();
+            
+      
+       s1=1;
+       s2=1;
+       s3=1;
+       s4=1;
+       s5=1;
+
+}
+
+void punt(int pos, int kleur)
+{
+
+ s5=0;
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+        
+         s5=1;
+
+}
+
+void Z(int pos, int kleur)
+{
+
+         s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(5+pos);
+         sendByte(0x84+kleur); 
+        send_position(6+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(5+pos);
+       
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur);
+        send_position(4+pos);
+         
+        s3=1;
+        s4=0;
+      
+          sendByte(0x84+kleur);
+        send_position(3+pos);
+        s4=1;
+        s5=0;
+          sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(5+pos);
+         sendByte(0x84+kleur); 
+        send_position(6+pos);
+         s5=1;
+        
+     /// ***** Eind Z ***/
+
+
+
+}
+
+void Y(int pos, int kleur)
+{
+
+ s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+       
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+           
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+  
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+      
+       
+        
+        s5=1;
+        
+      ///*** Eind Y **** ///
+
+
+}
+
+void X(int pos, int kleur)
+{
+
+ s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+       
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+           
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur);
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur);
+        send_position(6+pos);
+       
+        
+        s5=1;
+        
+      ///*** Eind X **** ///
+
+
+}
+
+void W(int pos, int kleur)
+{
+
+         s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(6+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(6+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur);
+        send_position(2+pos);
+        
+        sendByte(0x84+kleur);
+        send_position(6+pos);
+        
+        s3=1;
+        s4=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur);
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+      
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur);
+        send_position(5+pos);
+         s5=1;
+        
+     /// ***** Eind W ***/
+
+
+}
+
+void V(int pos, int kleur)
+{
+
+     s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(6+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(6+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(6+pos);
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+             
+         sendByte(0x84+kleur);
+        send_position(4+pos);
+         s5=1;
+        
+     /// ***** Eind V ***/
+
+
+}
+void U(int pos, int kleur)
+{
+
+         s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur);
+        send_position(4+pos);
+         s5=1;
+        
+     /// ***** Eind U ***/
+
+}
+
+void T(int pos, int kleur)
+{
+ s1=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+      sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+    
+         sendByte(0x84+kleur); 
+        send_position(5+pos);;
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+         
+        s2=1;
+        s3=0;
+        
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+       
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+     
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+        s5=1;
+       
+
+///** Einde T ***/
+
+}
+
+
+void S(int pos, int kleur)
+{
+
+ s1=0;
+        
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(2+pos);
+       
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur);
+        send_position(3+pos);
+          sendByte(0x84+kleur);
+        send_position(4+pos);
+        s3=1;
+        s4=0;
+      
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+             sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur);
+        send_position(4+pos);
+         s5=1;
+        
+     /// ***** Eind S ***/
+
+
+
+}
+void R(int pos, int kleur)
+{
+
+         s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+       
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        
+   
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         
+         
+              
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur);
+        send_position(4+pos);
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur);
+        send_position(5+pos);
+       
+        
+        s5=1;
+        
+      ///*** Eind R **** ///
+
+}
+
+void Q(int pos, int kleur)
+{
+
+ s1=0;
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(4+pos);
+         sendByte(0x84+kleur);
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+            sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+         sendByte(0x84+kleur);
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); 
+        send_position(6+pos);
+        
+         s5=1;
+        
+
+        
+      ///*** Eind Q **** ///
+
+
+
+}
+
+void P(int pos, int kleur)
+{
+
+ s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+       
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        
+   
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+        sendByte(0x84+kleur);
+         send_position(4+pos);
+         
+              
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+       
+        
+        s5=1;
+        
+      ///*** Eind P **** ///
+
+
+}
+
+void O(int pos, int kleur)
+{
+  s1=0;
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur);
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur);
+        send_position(4+pos);
+         s5=1;
+        
+     /// ***** Eind O ***/
+
+
+}
+
+void N(int pos, int kleur)
+{
+ s1=0;
+      sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+      
+      s1=1;
+      s2=0;
+      
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(3+pos);
+    
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+    
+        s2=1;
+     s3=0;   
+     
+       sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+        s3=1;
+        
+        s4=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(6+pos);
+            sendByte(0x84+kleur); 
+        send_position(5+pos);
+         s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(6+pos);
+       
+        s5=1;
+        
+      ///*** Eind  N**** ///
+
+
+
+}
+void M(int pos, int kleur)
+{
+
+ s1=0;
+      sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+      
+      s1=1;
+      s2=0;
+      
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(3+pos);
+        sendByte(0x84+kleur); 
+        send_position(5+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+    
+        s2=1;
+     s3=0;   
+     
+       sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(6+pos);
+        s3=1;
+        
+        s4=0;
+        
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(6+pos);
+        s4=1;
+        s5=1;
+        
+      ///*** Eind  M**** ///
+
+
+
+}
+
+
+void L(int pos, int kleur)
+{
+ s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+   
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+              
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+            
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s5=1;
+        
+      ///*** Eind L **** ///
+
+}
+
+void K(int pos, int kleur)
+{
+
+ s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+    
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(4+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(3+pos);
+  
+       
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur); 
+        send_position(4+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); 
+        send_position(2+pos);
+            sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s5=1;
+        
+      ///*** Eind K **** ///
+}
+
+void J(int pos, int kleur)
+{
+
+s1=0;
+ 
+      sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+    
+     
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+         
+        s2=1;
+        s3=0;
+        
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+       
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+     
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur);
+          send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+    
+     s5=1;
+
+///** Einde J ***/
+}
+void I(int pos, int kleur)
+{
+
+ s1=0;
+ 
+      sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+    
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+         
+        s2=1;
+        s3=0;
+        ;
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+       
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+     
+        s4=1;
+        s5=0;
+          send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+    
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+
+///** Einde I ***/
+}
+
+
+
+void H(int pos, int kleur)
+{     
+      //// *** Begin H *** // 
+       s1=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+    
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(3+pos);
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+          sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); 
+        send_position(2+pos);
+            sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s5=1;
+}  
+void G(int pos, int kleur)
+{
+      myled=1;
+      s1=0;
+       sendByte(0x84+kleur);
+        send_position(2+pos);
+         sendByte(0x84+kleur);
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur);
+        send_position(2+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(4+pos);
+        sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+        sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+          sendByte(0x84+kleur); 
+        send_position(2+pos);
+             sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+         sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s5=1;
+        
+}   
+      
+void F(int pos, int kleur){
+
+      s1=0;
+         sendByte(0x84+kleur); //
+        send_position(2+pos);
+         sendByte(0x84+kleur); //
+        send_position(3+pos);
+         sendByte(0x84+kleur); // 
+        send_position(4+pos);
+          sendByte(0x84+kleur); // 
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+        s2=1;
+        s3=0;
+       sendByte(0x84+kleur);
+        send_position(2+pos);
+         sendByte(0x84+kleur);
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+          sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+       sendByte(0x84+kleur); 
+        send_position(2+pos);
+        s4=1;
+        s5=0;
+          
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+         s5=1;
+     
+      /// **** Eind F ****///
+      
+}      
+      
+void E(int pos, int kleur)
+{
+       
+         s1=0;
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+          sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        s2=1;
+        s3=0;
+       sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+          sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+       sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); // 1 rode led aan
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+          sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s5=1;
+     
+       ///*** Eind E ***///
+}       
+void D(int pos, int kleur)
+{
+       s1=0;
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur);
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); 
+        send_position(2+pos);
+          sendByte(0x84+kleur); 
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); 
+        send_position(2+pos);
+         sendByte(0x84+kleur); 
+        send_position(3+pos);
+         sendByte(0x84+kleur); 
+        send_position(4+pos);
+        s5=1;
+       
+      //**** Eind D **** /// 
+}      
+
+void C(int pos, int kleur)
+{
+        s1=0;
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s1=1;
+        s2=0;
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        s3=1;
+        s4=0;
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        s4=1;
+        s5=0;
+             sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s5=1;
+        
+     /// ***** Eind C ***/
+}
+
+void B(int pos, int kleur)
+{    
+   
+       
+       s1=0;
+       sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+        s1=1;
+        s2=0;
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s2=1;
+        s3=0;
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+        s3=1;
+        s4=0;
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s4=1;
+        s5=0;
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+      
+        s5=1;
+      
+      //***** Eind B  *****/
+}
+
+void A(int pos,int kleur)
+{      
+      
+    
+      s1=0;
+      sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+      
+      s1=1;
+      s2=0;
+      
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+          sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+        s2=1;
+     s3=0;   
+     
+       sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(3+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(4+pos);
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(5+pos);
+          sendByte(0x84+kleur); // 1 rode led aan
+        send_position(6+pos);
+        s3=1;
+        
+        s4=0;
+        s5=0;
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(2+pos);
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(6+pos);
+        s4=1;
+        s5=1;
+     
+        //*********** Einde Letter A ****////
+}
+int main() {
+int i,x;
+fade.period_us(1);
+fade=0.5;
+ x=100; // aantal leds in de strip
+       s1=0;
+       s2=0;
+       s3=0;
+       
+       s4=0;
+       s5=0;
+       
+   for(i=0 ; i < x ; i++) // alle leds uitzetten om te kunnen beginnen.
+        {
+            sendByte(128);
+             latchen();
+        }
+      // s1=0;
+       s2=1;
+       s3=1;
+       s4=1;
+       s5=1;
+
+   while(1)
+      { 
+      int x;
+      for(i=0;i<92;i++){
+            erase();
+           
+           
+        
+       
+       /* N(0+i,0);
+        L(0+i,0);
+        punt(0+i,0);
+        D(0+i,0);
+        N(0+i,0);
+        U(0+i,0);
+        O(0+i,0);
+        S(0+i,0);
+        N(0+i,0);
+        L(0+i,0);*/
+   
+           
+               
+         /*  L(0+i-6,0);
+           N(0+i-13,0);
+           punt(0+i-17,9);
+           D(0+i-20,0);
+           N(0+i-26,14);
+           U(0+i-32,-3);
+           O(0+i-38,0x11);
+           S(0+i-44,0);
+           N(0+i-50,9);
+           L(0+i-56,14);
+           */
+           if(i>0){
+               
+                L(0+i-6,0);
+            }
+            
+            if(i>7){
+            N(0+i-13,0);
+            }
+            
+            if(i>11 ){
+            punt(0+i-17,9);
+            }
+            if(i>14 ){
+            D(0+i-20,0);
+            }
+            if(i>20){
+            N(0+i-26,14);
+            }
+            if(i>26){
+            U(0+i-32,-3);
+            }
+            if(i>32){
+           O(0+i-38,0x11);
+           }
+            if(i>38){
+           S(0+i-44,0);
+           }
+            if(i>44){
+           N(0+i-50,9);
+           }
+            if(i>50){
+           L(0+i-56,14);
+           }
+            
+            wait_ms(900);
+      
+        
+        
+       myled=0;
+       
+       
+           
+    }
+
+
+ /*********************Trial HOI op 1 strip ************************
+     
+       // Trial H
+         
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(10);
+        
+        
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(8);
+         
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(14+pos);
+        
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(15+pos);
+        
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(16+pos);
+        
+        
+        sendByte(0x84+kleur); // 1 rode led aan
+        send_position(36+pos);
+        
+         sendByte(0x84+kleur); // 1 rode led aan
+        send_position(34+pos);
+        
+        
+             
+        // Trial O
+        
+             
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(6+pos);
+        
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(5+pos);
+        
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(4+pos);
+        
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(18);
+        
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(32+pos);
+        
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(31);
+        
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(30);
+        
+        
+         sendByte(0x81); // 1 blauwe led aan
+        send_position(20);
+        
+        
+       // trial I
+       
+       
+        sendByte(0x95+pos); // 1 groene led aan // nu wit gemaakt
+        send_position(28);
+        
+        sendByte(0x95+pos); // 1 groene led aan
+        send_position(2+pos);
+        
+        sendByte(0x95+pos); // 1 groene led aan
+        send_position(22+pos);
+        
+        /************** End HOI ***********///////
+  }  }   
\ No newline at end of file