Denníček - február 2020: Rozdiel medzi revíziami
Skočit na navigaci
Skočit na vyhledávání
(Vytvorená stránka „Oliver naprogramoval prvú verziu rozpoznávania lopty: <syntaxhighlight lang="C"> int je_lopta(uint8_t r, uint8_t g, uint8_t b) { float h, s, v, max, min; h = 0;...“) |
dBez shrnutí editace |
||
Riadok 72: | Riadok 72: | ||
{ | { | ||
cnt++; | cnt++; | ||
} | |||
</syntaxhighlight> | |||
Martin s Jankom pracoval na kalibrácií senzorov, zatiaľ máme toto: | |||
<syntaxhighlight lang="C"> | |||
#define senzor A7 | |||
#define switch 7 | |||
int val = 0; | |||
int min, max; | |||
void setup() { | |||
Serial.begin(9600); | |||
Serial.println("Zacinam kalibraciu."); | |||
min=max=val=analogRead(senzor); | |||
pinMode(switch, INPUT_PULLUP); | |||
} | |||
void loop() { | |||
val=analogRead(senzor); | |||
if(val<min) | |||
min=val; | |||
if(val>max) | |||
max=val; | |||
Serial.print(" val: "); | |||
Serial.print(val); | |||
Serial.print(" min: "); | |||
Serial.print(min); | |||
Serial.print(" max: "); | |||
Serial.print(max); | |||
Serial.println(); | |||
while(digitalRead(switch) == LOW) { | |||
; | |||
} | |||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> |
Verzia z 16:12, 4. február 2020
Oliver naprogramoval prvú verziu rozpoznávania lopty:
int je_lopta(uint8_t r, uint8_t g, uint8_t b)
{
float h, s, v, max, min;
h = 0;
if (r < b){
if(r < g){
min = r;
}
else{
min = g;
}
}
else{
if (b < g){
min = b;
}
else{
min = g;
}
}
if (r > b){
if(r > g){
max = r;
if (max!= min){
h = 60*((g-b)/(max-min));
}
}
else{
max = g;
if (max!= min){
h = 60*(2+(b-r)/(max-min));
}
}
}
else{
if (b > g){
max = b;
if (max!= min){
h = 60*(4+(r-g)/(max - min));
}
}
else{
max = g;
if (max!= min){
h = 60*(2+(b-r)/(max - min));
}
}
}
v = max;
s = (max-min)/max;
if (h < 0){
h = h + 360;
}
if (h < 28 && h > 8 && s > 0.5 && v > 100){
return 1;
}
return 0;
}
//------------------
if (je_lopta(r,g,b) == 1)
{
cnt++;
}
Martin s Jankom pracoval na kalibrácií senzorov, zatiaľ máme toto:
#define senzor A7
#define switch 7
int val = 0;
int min, max;
void setup() {
Serial.begin(9600);
Serial.println("Zacinam kalibraciu.");
min=max=val=analogRead(senzor);
pinMode(switch, INPUT_PULLUP);
}
void loop() {
val=analogRead(senzor);
if(val<min)
min=val;
if(val>max)
max=val;
Serial.print(" val: ");
Serial.print(val);
Serial.print(" min: ");
Serial.print(min);
Serial.print(" max: ");
Serial.print(max);
Serial.println();
while(digitalRead(switch) == LOW) {
;
}
}