Lær lyskarakteristikker med 3D printet fyrlykt


Reklame - Artikkelen inneholder annonselenker

Dersom du har planer om å lære deg karakteristikkene på lys på sjøen, kan jeg anbefale å lage et slikt treningsfyr. Det har de fleste blinkene som er vanlig langs den norske kysten.  Lykten styres av en fjernkontroll, og koster under 100 kr å bygge dersom du har en 3D printer.

 

I forhold til fjernkontrollen har knappene følgende funksjon:

1 – Hurtigblink serien (Q, VQ, UQ)
2 – ISO serien (ISO2, ISO 4, ISO 6, ISO 8)
3 – FM serien (Oc6s, Oc2 8s, Oc 3 8s)
4 – Blink serien (Fl 4s, Fl 6s, Lfl 10s, Fl(2) 6s, Fl(3) 6s)
5 – Kardinal serien (Q, VQ(3)5s, VQ(6)+Lfl 10s, VQ(9)10s)
6 – Morse (SOS)
7 – Fast
8 – Fast
9 – Fast
* – Av
# – Tilfeldig
Pil opp – Veksle blink kategori – 
Pil ned –  Veksle blink kategori +
Pil venstre – Veksle blink karakteristikk –
Pil høyde – Veksle blink karakteristikk +
OK – AV/PÅ

 

Delene som er brukt (Lenker til AliExpress):

1 x Arduino Nano
1 x Green LED 5mm
1 x  Red LED 5mm
1 x White LED 5mm
1 x IR Remote control module
20 cm ledning

Printede deler (lastes ned fra Thingiverse):

1 x Bunn
1 x Tak

Koblingsskjema:

Koden:

// Include IR Remote Library by Ken Shirriff
#include 

// Define sensor pin
const int RECV_PIN = 4;
const int ledPin1 =  A0;
const int ledPin2 =  A1;

long previousMillis = 0;
long previousMillis2 = 0;

int ledState = LOW; 

// Define IR Receiver and Results Objects
IRrecv irrecv(RECV_PIN);
decode_results results;

 int verdi2 = 0;
 int verdi1 = 0;
void setup(){
  // Serial Monitor @ 9600 baud
  Serial.begin(9600);
  // Enable the IR Receiver
  irrecv.enableIRIn();
  pinMode (ledPin1, OUTPUT);
  pinMode (ledPin2, OUTPUT);
}
 
void loop(){

unsigned long currentMillis = millis();
  
  if (irrecv.decode(&results)){
    // Print Code in HEX
    //    Serial.println(results.value, HEX);

   switch(results.value)
   {
    case 0xFFA25D:

     Serial.println("Quick Serien");
     verdi1 = 1;
     break;
     case 0xFF629D:
     Serial.println("ISO");
     verdi1 = 2;
     break;
     case 0xFFE21D:
     Serial.println("FM");
     verdi1 = 3;
     break;
      case 0xFF22DD:
     Serial.println("Flash");
     verdi1 = 4;
     break;
      case 0xFF02FD:
     Serial.println("Kardinal");
     verdi1 = 5;
     break;
      case 0xFFC23D:
     Serial.println("Morse");
     verdi1 = 6;
     break;
      case 0xFFE01F:
     Serial.println("7");
     verdi1 = 8;
     break;
      case 0xFFA857:
     Serial.println("8");
     verdi1 = 8;
     break;
      case 0xFF906F:
     Serial.println("9");
     verdi1 = 8;
     break;
      case 0xFF9867:
     Serial.println("AV");
     verdi1 = 7;
     break;
      case 0xFF6897:
     Serial.println("*");
       Serial.println("Fast");
       verdi1 = 8;
     break;
      case 0xFFB04F:
     Serial.println("#");
     verdi1 = random(1,6);
     verdi2 = random(0,4);
     Serial.println(verdi1);
     break;
      case 0xFF18E7:
     Serial.println("o");
     if (verdi1 <= 5) { verdi1 = verdi1 + 1; Serial.println(verdi1); } else { verdi1 = 1; Serial.println(verdi1); } break; case 0xFF4AB5: Serial.println("n"); if (verdi1 >= 2) {
     verdi1 = verdi1 - 1;
     Serial.println(verdi1);
     }
     else {
      verdi1 = 6;
      Serial.println(verdi1);
      }
     break;
      case 0xFF10EF:
     Serial.println("V");
     if (verdi2 >= 2) {
     verdi2 = verdi2 - 1;
     Serial.println(verdi2);
     }
     else {
      verdi2 = 9;
      Serial.println(verdi2);
      }
     break;
      case 0xFF5AA5:
     Serial.println("H");
     if (verdi2 <= 8) { verdi2 = verdi2 + 1; Serial.println(verdi2); } else { verdi2 = 0; Serial.println(verdi2); } break; case 0xFF38C7: Serial.println("OK"); if (verdi1 !=7) { verdi1 = 7; } else { verdi1 = 8; } break; } irrecv.resume(); } switch(verdi1) { case 1: switch(verdi2) { case 0: //Q blinkOff(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 1000 ) blinkOn(); if(currentMillis - previousMillis > 1000) previousMillis = currentMillis;   
   break; 

case 1: // VQ
blinkOff(); 
if(currentMillis - previousMillis > 250 && currentMillis - previousMillis < 500 ) blinkOn(); if(currentMillis - previousMillis > 500) previousMillis = currentMillis;  
break;

case 2: // UQ
blinkOff(); 
if(currentMillis - previousMillis > 125 && currentMillis - previousMillis < 250 ) blinkOn(); if(currentMillis - previousMillis > 250) previousMillis = currentMillis; 
break;    

case 3:
verdi2 = 0;
break;
case 4:
verdi2 = 0;
break;
case 5:
verdi2 = 0;
break;
case 6:
verdi2 = 0;
break;
case 7:
verdi2 = 0;
break;
case 8:
verdi2 = 0;
break;
case 9:
verdi2 = 2;
break;
}
break;

case 2: //ISO
switch(verdi2) {

  case 0: //ISO1
  blinkOff(); 
if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 1000 ) blinkOn(); if(currentMillis - previousMillis > 1000) previousMillis = currentMillis;
   break; 

case 1: // ISO2
blinkOff(); 
if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 2000 ) blinkOn(); if(currentMillis - previousMillis > 2000) previousMillis = currentMillis;
break;

case 2: // ISO 4
blinkOff(); 
if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 4000 ) blinkOn(); if(currentMillis - previousMillis > 4000) previousMillis = currentMillis;
break;    

case 3: // ISO6
blinkOff(); 
if(currentMillis - previousMillis > 3000 && currentMillis - previousMillis < 6000 ) blinkOn(); if(currentMillis - previousMillis > 6000) previousMillis = currentMillis;
break;
case 4: // ISO8
 blinkOff(); 
if(currentMillis - previousMillis > 4000 && currentMillis - previousMillis < 8000 ) blinkOn(); if(currentMillis - previousMillis > 8000) previousMillis = currentMillis;
break;
case 5:
verdi2 = 0;
break;
case 6:
verdi2 = 0;
break;
case 7:
verdi2 = 0;
break;
case 8:
verdi2 = 0;
break;
case 9:
verdi2 = 4;
break;
}
break;

case 3: //FM / OC
switch(verdi2) {

  case 0: //FM1
   blinkOff(); 

if(currentMillis - previousMillis >1000) blinkOn();
if(currentMillis - previousMillis > 6000) previousMillis = currentMillis;
   break; 

case 1: // FM2
 blinkOff(); 
if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 2000 ) blinkOn(); if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 3000 ) blinkOff(); if(currentMillis - previousMillis > 3000 && currentMillis - previousMillis < 8000) blinkOn(); if(currentMillis - previousMillis > 8000) previousMillis = currentMillis;
break;

case 2: // FM3
blinkOff(); 
if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 2000 ) blinkOn(); if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 3000 ) blinkOff(); if(currentMillis - previousMillis > 3000 && currentMillis - previousMillis < 4000) blinkOn(); if(currentMillis - previousMillis > 4000 && currentMillis - previousMillis < 5000 ) blinkOff(); if(currentMillis - previousMillis > 5000 && currentMillis - previousMillis < 8000) blinkOn(); if(currentMillis - previousMillis > 8000) previousMillis = currentMillis;
break;    

case 3: // 
verdi2 = 0;
break;
case 4: //
verdi2 = 0;
break;
case 5:
verdi2 = 0;
break;
case 6:
verdi2 = 0;
break;
case 7:
verdi2 = 0;
break;
case 8:
verdi2 = 0;
break;
case 9:
verdi2 = 2;
break;
}
break;


case 4: //Flash
switch(verdi2) {

  case 0: //Fl 4s
if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 500 ) blinkOn(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 4000 ) blinkOff(); if(currentMillis - previousMillis > 4000) previousMillis = currentMillis;
   break; 

case 1: // Fl 6s
 if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 500 ) blinkOn(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 6000 ) blinkOff(); if(currentMillis - previousMillis > 6000) previousMillis = currentMillis; 
break;

case 2: // LF 10s
if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 2000 ) blinkOn(); if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 10000 ) blinkOff(); if(currentMillis - previousMillis > 10000) previousMillis = currentMillis;
break;    

case 3: // Fl(2) 6s 
if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 500 ) blinkOn(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 1000 ) blinkOff(); if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 1500 ) blinkOn(); if(currentMillis - previousMillis > 1500 && currentMillis - previousMillis < 6000 ) blinkOff(); if(currentMillis - previousMillis > 6000) previousMillis = currentMillis; 
break;
case 4: // Fl(3) 6s 
if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 500 ) blinkOn(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 1000 ) blinkOff(); if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 1500 ) blinkOn(); if(currentMillis - previousMillis > 1500 && currentMillis - previousMillis < 2000 ) blinkOff(); if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 2500 ) blinkOn(); if(currentMillis - previousMillis > 2500 && currentMillis - previousMillis < 6000 ) blinkOff(); if(currentMillis - previousMillis > 6000) previousMillis = currentMillis; 
break;
case 5:
verdi2 = 0;
break;
case 6:
verdi2 = 0;
break;
case 7:
verdi2 = 0;
break;
case 8:
verdi2 = 0;
break;
case 9:
verdi2 = 4;
break;
}
break;

case 5: //Kardinal
switch(verdi2) {

  case 0: //Nord
blinkOff(); 
if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 1000 ) blinkOn(); if(currentMillis - previousMillis > 1000) previousMillis = currentMillis;   
   break; 

case 1: // Øst
 if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 250 ) blinkOn(); if(currentMillis - previousMillis > 250 && currentMillis - previousMillis < 500 ) blinkOff(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 750 ) blinkOn(); if(currentMillis - previousMillis > 750 && currentMillis - previousMillis < 1000 ) blinkOff(); if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 1250 ) blinkOn(); if(currentMillis - previousMillis > 1250 && currentMillis - previousMillis < 5000 ) blinkOff(); if(currentMillis - previousMillis > 5000) previousMillis = currentMillis;  
break;

case 2: // Sør
if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 250 ) blinkOn(); if(currentMillis - previousMillis > 250 && currentMillis - previousMillis < 500 ) blinkOff(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 750 ) blinkOn(); if(currentMillis - previousMillis > 750 && currentMillis - previousMillis < 1000 ) blinkOff(); if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 1250 ) blinkOn(); if(currentMillis - previousMillis > 1250 && currentMillis - previousMillis < 1500 ) blinkOff(); if(currentMillis - previousMillis > 1500 && currentMillis - previousMillis < 1750 ) blinkOn(); if(currentMillis - previousMillis > 1750 && currentMillis - previousMillis < 2000 ) blinkOff(); if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 2250 ) blinkOn(); if(currentMillis - previousMillis > 2250 && currentMillis - previousMillis < 2500 ) blinkOff(); if(currentMillis - previousMillis > 2500 && currentMillis - previousMillis < 2750 ) blinkOn(); if(currentMillis - previousMillis > 2750 && currentMillis - previousMillis < 3000 ) blinkOff(); if(currentMillis - previousMillis > 3000 && currentMillis - previousMillis < 5000 ) blinkOn(); if(currentMillis - previousMillis > 5000 && currentMillis - previousMillis < 10000 ) blinkOff(); if(currentMillis - previousMillis > 10000) previousMillis = currentMillis;  
break;    

case 3: // vest
if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 250 ) blinkOn(); if(currentMillis - previousMillis > 250 && currentMillis - previousMillis < 500 ) blinkOff(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 750 ) blinkOn(); if(currentMillis - previousMillis > 750 && currentMillis - previousMillis < 1000 ) blinkOff(); if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 1250 ) blinkOn(); if(currentMillis - previousMillis > 1250 && currentMillis - previousMillis < 1500 ) blinkOff(); if(currentMillis - previousMillis > 1500 && currentMillis - previousMillis < 1750 ) blinkOn(); if(currentMillis - previousMillis > 1750 && currentMillis - previousMillis < 2000 ) blinkOff(); if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 2250 ) blinkOn(); if(currentMillis - previousMillis > 2250 && currentMillis - previousMillis < 2500 ) blinkOff(); if(currentMillis - previousMillis > 2500 && currentMillis - previousMillis < 2750 ) blinkOn(); if(currentMillis - previousMillis > 2750 && currentMillis - previousMillis < 3000 ) blinkOff(); if(currentMillis - previousMillis > 3000 && currentMillis - previousMillis < 3250 ) blinkOn(); if(currentMillis - previousMillis > 3250 && currentMillis - previousMillis < 3500 ) blinkOff(); if(currentMillis - previousMillis > 3500 && currentMillis - previousMillis < 3750 ) blinkOn(); if(currentMillis - previousMillis > 3750 && currentMillis - previousMillis < 4000 ) blinkOff(); if(currentMillis - previousMillis > 4250 && currentMillis - previousMillis < 4500 ) blinkOn(); if(currentMillis - previousMillis > 4500 && currentMillis - previousMillis < 10000 ) blinkOff(); if(currentMillis - previousMillis > 10000) previousMillis = currentMillis; 
break;
case 4: //
verdi2 = 0;
break;
case 5:
verdi2 = 0;
break;
case 6:
verdi2 = 0;
break;
case 7:
verdi2 = 0;
break;
case 8:
verdi2 = 0;
break;
case 9:
verdi2 = 2;
break;
}
break;
case 6: //Kardinal
switch(verdi2) {

  case 0: //Nord
if(currentMillis - previousMillis > 0 && currentMillis - previousMillis < 250 ) blinkOn(); //. if(currentMillis - previousMillis > 250 && currentMillis - previousMillis < 500 ) blinkOff(); if(currentMillis - previousMillis > 500 && currentMillis - previousMillis < 750 ) blinkOn();//. if(currentMillis - previousMillis > 750 && currentMillis - previousMillis < 1000 ) blinkOff(); if(currentMillis - previousMillis > 1000 && currentMillis - previousMillis < 1250 ) blinkOn();//. if(currentMillis - previousMillis > 1250 && currentMillis - previousMillis < 2000 ) blinkOff(); if(currentMillis - previousMillis > 2000 && currentMillis - previousMillis < 2750 ) blinkOn();//- if(currentMillis - previousMillis > 2750 && currentMillis - previousMillis < 3000 ) blinkOff(); if(currentMillis - previousMillis > 3000 && currentMillis - previousMillis < 3750 ) blinkOn();//- if(currentMillis - previousMillis > 3750 && currentMillis - previousMillis < 4000 ) blinkOff(); if(currentMillis - previousMillis > 4000 && currentMillis - previousMillis < 4750 ) blinkOn();//- if(currentMillis - previousMillis > 4750 && currentMillis - previousMillis < 5500 ) blinkOff(); if(currentMillis - previousMillis > 5500 && currentMillis - previousMillis < 5750 ) blinkOn();//. if(currentMillis - previousMillis > 5750 && currentMillis - previousMillis < 6000 ) blinkOff(); if(currentMillis - previousMillis > 6000 && currentMillis - previousMillis < 6250 ) blinkOn();//. if(currentMillis - previousMillis > 6250 && currentMillis - previousMillis < 6500 ) blinkOff(); if(currentMillis - previousMillis > 6500 && currentMillis - previousMillis < 6750 ) blinkOn();//. if(currentMillis - previousMillis > 6750 && currentMillis - previousMillis < 8000 ) blinkOff(); if(currentMillis - previousMillis > 8000) previousMillis = currentMillis;
   break; 

case 1: // 
verdi2 = 0; 
break;

case 2: // 
verdi2 = 0;
break;    

case 3: // 
verdi2 = 0;
break;
case 4: //
verdi2 = 0;
break;
case 5:
verdi2 = 0;
break;
case 6:
verdi2 = 0;
break;
case 7:
verdi2 = 0;
break;
case 8:
verdi2 = 0;
break;
case 9:
verdi2 = 0;
break;
}
break;

case 7:
blinkOff(); 
break;

case 8:
blinkOn();
break;
}
}


void blinkOn()
{
analogWrite(ledPin1, 130);
digitalWrite(ledPin2, HIGH);
delay(30);
analogWrite(ledPin1, 255);
}

void blinkOff()
{
digitalWrite(ledPin1, LOW);
digitalWrite(ledPin2, LOW);
}



Legg igjen en kommentar

Din e-postadresse vil ikke bli publisert. Obligatoriske felt er merket med *