Hello,
i want to controll my LED-Cube, with the FEZ Panda II.
The LED-Cube should start when the infrared photocell is broke through.
The LED-Cube is working without the infrared photocell but with it it doestn work.
Here is my C# source code:
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
namespace FEZ_Panda_II_Application1
{
public class Program
{
public static void Main()
{
InputPort In1 = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di0, true, Port.ResistorMode.PullUp);
OutputPort layer_1 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di26, false);
OutputPort layer_2 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di28, false);
OutputPort layer_3 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di35, false);
OutputPort layer_4 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di36, false);
//Led 1-9
OutputPort pin_1 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di20, false);
OutputPort pin_2 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di22, false);
OutputPort pin_3 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di24, false);
OutputPort pin_4 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di30, false);
OutputPort pin_5 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di32, false);
OutputPort pin_6 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di34, false);
OutputPort pin_7 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di38, false);
OutputPort pin_8 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di40, false);
OutputPort pin_9 = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di42, false);
while (true)
{
if (In1.Read() == false)
{
layer_1.Write(false);
layer_2.Write(true);
layer_3.Write(true);
layer_4.Write(true);
pin_1.Write(!pin_1.Read());
Thread.Sleep(150);
pin_1.Write(!pin_1.Read());
pin_2.Write(!pin_2.Read());
Thread.Sleep(150);
pin_2.Write(!pin_2.Read());
pin_3.Write(!pin_3.Read());
Thread.Sleep(150);
pin_3.Write(!pin_3.Read());
pin_6.Write(!pin_6.Read());
Thread.Sleep(150);
pin_6.Write(!pin_6.Read());
pin_5.Write(!pin_5.Read());
Thread.Sleep(150);
pin_5.Write(!pin_5.Read());
pin_4.Write(!pin_4.Read());
Thread.Sleep(150);
pin_4.Write(!pin_4.Read());
pin_7.Write(!pin_7.Read());
Thread.Sleep(150);
pin_7.Write(!pin_7.Read());
pin_8.Write(!pin_8.Read());
Thread.Sleep(150);
pin_8.Write(!pin_8.Read());
pin_9.Write(!pin_9.Read());
Thread.Sleep(150);
pin_9.Write(!pin_9.Read());
layer_1.Write(true);
layer_2.Write(false);
layer_3.Write(true);
layer_4.Write(true);
pin_9.Write(!pin_9.Read());
Thread.Sleep(150);
pin_9.Write(!pin_9.Read());
pin_8.Write(!pin_8.Read());
Thread.Sleep(150);
pin_8.Write(!pin_8.Read());
pin_7.Write(!pin_7.Read());
Thread.Sleep(150);
pin_7.Write(!pin_7.Read());
pin_4.Write(!pin_4.Read());
Thread.Sleep(150);
pin_4.Write(!pin_4.Read());
pin_5.Write(!pin_5.Read());
Thread.Sleep(150);
pin_5.Write(!pin_5.Read());
pin_6.Write(!pin_6.Read());
Thread.Sleep(150);
pin_6.Write(!pin_6.Read());
pin_3.Write(!pin_3.Read());
Thread.Sleep(150);
pin_3.Write(!pin_3.Read());
pin_2.Write(!pin_2.Read());
Thread.Sleep(150);
pin_2.Write(!pin_2.Read());
pin_1.Write(!pin_1.Read());
Thread.Sleep(150);
pin_1.Write(!pin_1.Read());
layer_1.Write(true);
layer_2.Write(true);
layer_3.Write(false);
layer_4.Write(true);
pin_1.Write(!pin_1.Read());
Thread.Sleep(150);
pin_1.Write(!pin_1.Read());
pin_2.Write(!pin_2.Read());
Thread.Sleep(150);
pin_2.Write(!pin_2.Read());
pin_3.Write(!pin_3.Read());
Thread.Sleep(150);
pin_3.Write(!pin_3.Read());
pin_6.Write(!pin_6.Read());
Thread.Sleep(150);
pin_6.Write(!pin_6.Read());
pin_5.Write(!pin_5.Read());
Thread.Sleep(150);
pin_5.Write(!pin_5.Read());
pin_4.Write(!pin_4.Read());
Thread.Sleep(150);
pin_4.Write(!pin_4.Read());
pin_7.Write(!pin_7.Read());
Thread.Sleep(150);
pin_7.Write(!pin_7.Read());
pin_8.Write(!pin_8.Read());
Thread.Sleep(150);
pin_8.Write(!pin_8.Read());
pin_9.Write(!pin_9.Read());
Thread.Sleep(150);
pin_9.Write(!pin_9.Read());
layer_1.Write(true);
layer_2.Write(true);
layer_3.Write(true);
layer_4.Write(false);
pin_9.Write(!pin_9.Read());
Thread.Sleep(150);
pin_9.Write(!pin_9.Read());
pin_8.Write(!pin_8.Read());
Thread.Sleep(150);
pin_8.Write(!pin_8.Read());
pin_7.Write(!pin_7.Read());
Thread.Sleep(150);
pin_7.Write(!pin_7.Read());
pin_4.Write(!pin_4.Read());
Thread.Sleep(150);
pin_4.Write(!pin_4.Read());
pin_5.Write(!pin_5.Read());
Thread.Sleep(150);
pin_5.Write(!pin_5.Read());
pin_6.Write(!pin_6.Read());
Thread.Sleep(150);
pin_6.Write(!pin_6.Read());
pin_3.Write(!pin_3.Read());
Thread.Sleep(150);
pin_3.Write(!pin_3.Read());
pin_2.Write(!pin_2.Read());
Thread.Sleep(150);
pin_2.Write(!pin_2.Read());
pin_1.Write(!pin_1.Read());
Thread.Sleep(150);
pin_1.Write(!pin_1.Read());
layer_1.Write(true);
layer_2.Write(true);
layer_3.Write(false);
layer_4.Write(true);
pin_1.Write(!pin_1.Read());
Thread.Sleep(150);
pin_1.Write(!pin_1.Read());
layer_1.Write(true);
layer_2.Write(false);
layer_3.Write(true);
layer_4.Write(true);
pin_1.Write(!pin_1.Read());
Thread.Sleep(150);
pin_1.Write(!pin_1.Read());
}
}
}
}
}