mirror of
https://github.com/nikdoof/website-hugo.git
synced 2025-12-14 08:02:19 +00:00
Update index.md
Better approach for final code.
This commit is contained in:
@@ -512,31 +512,35 @@ int main(void)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
for ( int led = 0 ; led < ledCount ; led ++ )
|
liPos = 0;
|
||||||
|
for ( int t = 0 ; t < ledCount*2; t++)
|
||||||
{
|
{
|
||||||
if ( led == currPos )
|
for ( int led = 0 ; led < ledCount ; led ++ )
|
||||||
{
|
{
|
||||||
// Send a blue colour at the correct position.
|
if ( led == currPos )
|
||||||
ws_send_byte( 0b00000000 );
|
{
|
||||||
ws_send_byte( 0b00000000 );
|
// Send a blue colour at the correct position.
|
||||||
ws_send_byte( 0x34 );
|
ws_send_byte( 0b00000000 );
|
||||||
|
ws_send_byte( 0b00000000 );
|
||||||
|
ws_send_byte( 0x34 );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Reset the LED when not at the correct position.
|
||||||
|
ws_send_byte( 0b00000000 );
|
||||||
|
ws_send_byte( 0b00000000 );
|
||||||
|
ws_send_byte( 0b00000000 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
liPos++;
|
||||||
{
|
currPos = ((liPos + ledCount) % (ledCount*2)) - ledCount ;
|
||||||
// Reset the LED when not at the correct position.
|
|
||||||
ws_send_byte( 0b00000000 );
|
|
||||||
ws_send_byte( 0b00000000 );
|
|
||||||
ws_send_byte( 0b00000000 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
liPos++;
|
|
||||||
currPos = ((liPos + ledCount) % (ledCount*2)) - ledCount ;
|
|
||||||
|
|
||||||
// Invert the position to track back and forth.
|
// Invert the position to track back and forth.
|
||||||
if ( currPos < 0 )
|
if ( currPos < 0 )
|
||||||
currPos = currPos * -1;
|
currPos = currPos * -1;
|
||||||
|
|
||||||
__delay_us(100);
|
__delay_us(100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user