Kapitán Spiccato a Major Espressivo: Rozdiel medzi revíziami
Skočit na navigaci
Skočit na vyhledávání
dBez shrnutí editace |
dBez shrnutí editace |
||
Riadok 1: | Riadok 1: | ||
__NOEDITSECTION__ | |||
[[Image:dron_program.png]] | [[Image:dron_program.png]] | ||
Aktuálna revízia z 03:14, 16. november 2024
15. nov. 2024
Arduino a displej 8x8:
rozsvietenie rámčeka:
#include "MaxLedControl.h"
LedControl lc=LedControl(11,13,7,1);
void setup() {
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}
void loop() {
int r, c, stav;
for (stav = 1; stav >= 0; stav--)
{
for (r = 0; r < 8; r++)
{
lc.setLed(0,r,0,stav);
delay(300);
}
for (c = 1; c < 8; c++)
{
lc.setLed(0,7,c,stav);
delay(300);
}
for (r = 6; r >= 0; r--)
{
lc.setLed(0,r,7,stav);
delay(300);
}
for (c = 6; c > 0; c--)
{
lc.setLed(0,0,c,stav);
delay(300);
}
}
}
Riadenie LED pomocou joysticku:
#include "MaxLedControl.h"
LedControl lc=LedControl(11,13,7,1);
int x = 3;
int y = 3;
void setup() {
Serial.begin(9600);
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
pinMode(5, OUTPUT);
digitalWrite(5, 1);
lc.setLed(0,x,y,1);
}
void loop() {
if (digitalRead(14))
{
Serial.println("click");
}
int osx = analogRead(1);
int osy = analogRead(2);
Serial.print(osx);
Serial.print(" ");
Serial.println(osy);
if ((osx < 400) && (x > 0))
{
lc.setLed(0,x,y,0);
x--;
lc.setLed(0,x,y,1);
delay(500);
}
if ((osx > 630) && (x < 7))
{
lc.setLed(0,x,y,0);
x++;
lc.setLed(0,x,y,1);
delay(500);
}
if ((osy < 400) && (y > 0))
{
lc.setLed(0,x,y,0);
y--;
lc.setLed(0,x,y,1);
delay(500);
}
if ((osy > 630) && (y < 7))
{
lc.setLed(0,x,y,0);
y++;
lc.setLed(0,x,y,1);
delay(500);
}
}
Prvé misie: