I tried in a lot of different approaches, but nothing did work.
I thought this way would work:
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
public class HelloWorld
{
public static void Main()
{
OutputPort[] target_LED = new OutputPort[1];
target_LED[0] = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di26, false);
InputPort newball_but = new InputPort((Cpu.Pin)FEZ_Pin.Digital.Di39, true, Port.ResistorMode.PullUp);
}
public HelloWorld()
{
if (newball_but.Read() == false)
{
target_LED[0].Write(true);
}
}
}
I just took one LED and one Button to try if it works.
But what I want is that there is one bonus-button and 5 other buttons with each one with one LED with the same number.
(button1 + led1, button2 + led2, button3+ led3, ⊠)
When the bonus-button is hit, a random number will be choosen and the LED with that number goes ON (true).
when the player hits the button with the same number, the score will add 40 points.
The number will be randomly choosen with:
Random random_gen = new Random();
int random_number = random_gen.Next(5);
the LED with that number will go on with this code:
if (targetBonus_but.Read() == false)
{
target_LED[random_number].Write(true);
}
And I thought I needed this code to give the player 40 points when he hits the button with the LED that is on. (with the same number)
if (target_LED[random_number].Read() == true && target_but[random_number].Read() == false)
{
score += 40;
target_LED[random_number].Write(false);
}
And when the player hits a button whit an LED that is OFF, he will get 20 points. For that part I use this code
if (target_but[0].Read() == false || target_but[1].Read() == false || target_but[2].Read() == false || target_but[3].Read() == false || target_but[4].Read() == false)
{
score += 20;
Thread.Sleep(200);
}
But the score doesnât add 40 in stead of 20 when the player hits the button with the LED that is on (it just adds 20âŠ)
So can someone help me to get this done?
(Iâm sorry if my english is bad or someone doesnât understand me. Iâm dutch and tired at the moment. So my brains donât work that good )