I want to switch on LED`s to visually show an address. So I want to cycle through addresses from 1 to 255 and display the binary address with LED´s. I have no idea how to do this.
Hello cookie1310
Post your sketch, well formated, with comments and in so called code tags "</>" and a none-Fritzing schematic to see how we can help.
so you want to indicate the value of each bit with an LED
for (int adr = 0; adr < 256; adr++) {
byte val = adr;
for (int n = 0; n < 8; n++) {
digitalWrite (PinLed [n], val & 1);
val >>= 1;
}
}
thanks, will give it a try.
Here is my simple code.
//Program to represent binary numbers by LEDs
int PinLed[8];
void setup()
{
// put your setup code here, to run once:
//Set pins to output
for (int PinLed = 2; PinLed <10; PinLed++)
{
pinMode(PinLed, OUTPUT);
}
//Turn LEDs on according to number
for (int adr = 0; adr < 256; adr++)
{
byte val = adr;
for (int n = 0; n < 8; n++)
{
digitalWrite (PinLed [n], val & 1);
val >>= 1;
}
delay(100);
}
}
void loop() {
// put your main code here, to run repeatedly:
}
What am I missing as it does nothing? I am pretty ignorant as far as coding is concerned. I suspect i have to define the pins but could not get this to work.
you need to specify the pin values that you're using in the array
byte PinLed [] = { 2, 3, 4, 5, ... };
Brilliant! Thanks.
Different but related. How do i upload a sketch to an eeprom programmer such as xgecu t48. Do i have to write an interface?
assume there's some application you can install that interfaces to it thru USB
Yes it has its own software. Not sure whether I have to remove comments or just upload it. Guess should just try it.
And once the pin numbers are in an array, never refer to them directly, always use the values from the array, viz:
for (int n = 0; n < 8; n++)
{
pinMode(PinLed[n], OUTPUT);
}
Then if you rewire things, you have only referred to the physical pin numbers in one place , so only one place where code needs to change to accommodate that change.
a7
usually need some form of a binary file, not source
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.