Varför får jag detta fel på en hämtad kod? (bild)

PIC, AVR, Arduino, Raspberry Pi, Basic Stamp, PLC mm.
Användarvisningsbild
teljemo
Inlägg: 1622
Blev medlem: 5 februari 2011, 12:08:13
Ort: Getinge
Kontakt:

Varför får jag detta fel på en hämtad kod? (bild)

Inlägg av teljemo »

Laddat ner kod och schema..
Installerat biblotek från hanteraren..

Får de här felet direkt?
Capture.PNG
Du har inte behörighet att öppna de filer som bifogats till detta inlägg.
ToPNoTCH
Inlägg: 4847
Blev medlem: 21 december 2009, 17:59:48

Re: Varför får jag detta fel på en hämtad kod? (bild)

Inlägg av ToPNoTCH »

Har du kollat detta exempel.

Det skiljer sig markant från din kod (Inget wire definerat etc.)

https://github.com/NorthernWidget/DS323 ... o_time.pde
Användarvisningsbild
hawkan
Inlägg: 2586
Blev medlem: 14 augusti 2011, 10:27:40

Re: Varför får jag detta fel på en hämtad kod? (bild)

Inlägg av hawkan »

Är det inte ett par rader till i nedersta fönstret?
Gör det större, det kan hända det står något där som kan hjälpa.
Användarvisningsbild
teljemo
Inlägg: 1622
Blev medlem: 5 februari 2011, 12:08:13
Ort: Getinge
Kontakt:

Re: Varför får jag detta fel på en hämtad kod? (bild)

Inlägg av teljemo »

laddade ner ett nytt DS3132 bibliotek från: http://www.rinkydinkelectronics.com/library.php?id=73
Det gjorde att jag kunde compilera koden..

Det är en kod för en neopixel cirkel som ska lysa som en klocka..
Funkade ändå inte..
Kanske för att jag har fler leds i min cirkel än i koden? min cirkel har 24 leds.. lyser inte alls..
schematic.jpg

Kod: Markera allt

//LEDclock by Max Power
//dont forget to download and install the right librarys or it wont work
//https://youtu.be/5dc_WO8sIWc




#include <Adafruit_NeoPixel.h>                      //you need to get the Adafruit_Neopixel.h library !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#define PIN 6 //led pin

#include <DS3231.h>                                 //you need to get the DS3231.h library            !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
DS3231  rtc(SDA, SCL);


int salt;
float dim;
float stp=.016; //play with this value if the pulsing isnt right

 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
 
void setup()
{
  strip.begin();      //initializing led strip
  rtc.begin();        //initializing clock
  Serial.begin(9600); //initializing serial


  rtc.setDOW(SATURDAY);    //set day
  rtc.setTime(9, 6, 00); //set time   
  rtc.setDate(6, 5, 2017); //set date

}
void loop()
{

  //setting variables
  String rtc_sec = "";
  String rtc_min = "";
  String rtc_hour = "";
  
  int led_sec = 0;
  int led_min = 0;
  int led_hour = 0;

  int pixel[12][3];

  //getting time from clock
  rtc_sec = getValue(rtc.getTimeStr(), ':',2);
  rtc_min = getValue(rtc.getTimeStr(), ':',1);
  rtc_hour = getValue(rtc.getTimeStr(), ':',0);

  //converting time to 12 leds
  led_sec=round((rtc_sec.toInt()+2)/5);
  if(led_sec==12){led_sec=0;}
  //if(rtc_min.toInt()<58 && rtc_min.toInt()>=3
  led_min=round((rtc_min.toInt()+2)/5);
  if(led_min==12){led_min=0;}
  led_hour=round(rtc_hour.toInt());
  if(led_hour>11){led_hour=led_hour-12;}

//resetting all leds to 0
for(int x=0;x<12;x++){
  for(int y=0;y<3;y++){ 
    pixel[x][y]=0; 
  }
 }

//lighting up the right leds
for(int x=0;x<12;x++){
  if(x==led_sec){
    pixel[x][0]=255;    //seconds are red
  }
  if(x==led_min){
    pixel[x][1]=255;    //minutes are green
  }
  if(x==led_hour){
    pixel[x][2]=255;    //hours are blue
  }
}



if(salt < rtc_sec.toInt()){     //tracking if second has passed
  dim=0;                        //resetting blinking every second
  
}
salt=rtc_sec.toInt();           //setting current second for future check

dim+=stp;                       //increment pulsing variable by defined amount


//changing led brightness according to -cos pulse
for(int x=0;x<12;x++){
  for(int y=0;y<3;y++){
    if(rtc_hour.toInt()<22 && rtc_hour.toInt()>=7){      //no blinking between 22 and 7 o clock
    pixel[x][y]=pixel[x][y]*((-cos(dim)+1)/2);
    }
  }
  }

//dimm led a bit when its between 20 and 9 o clock
if(rtc_hour.toInt()>=20 || rtc_hour.toInt()<9){
  for(int x=0;x<12;x++){
  for(int y=0;y<3;y++){
    
    pixel[x][y]=pixel[x][y]/10;
    
  }
  }
}

//dimm led some more when its between 22 and 7 o clock
if(rtc_hour.toInt()>=22 || rtc_hour.toInt()<7){
  for(int x=0;x<12;x++){
  for(int y=0;y<3;y++){
    
    pixel[x][y]=pixel[x][y]/10;
    
  }
  }
}

//display all calculated led values
for(int x=0;x<12;x++){

  strip.setPixelColor(x, strip.Color(pixel[x][0],pixel[x][1],pixel[x][2]));
  
}

    strip.show();


}
  


//useful to split rtc response into time
String getValue(String data, char separator, int index)
{
 int found = 0;
  int strIndex[] = {
0, -1  };
  int maxIndex = data.length()-1;
  for(int i=0; i<=maxIndex && found<=index; i++){
  if(data.charAt(i)==separator || i==maxIndex){
  found++;
  strIndex[0] = strIndex[1]+1;
  strIndex[1] = (i == maxIndex) ? i+1 : i;
  }
 }
  return found>index ? data.substring(strIndex[0], strIndex[1]) : "";
}
Du har inte behörighet att öppna de filer som bifogats till detta inlägg.
Skriv svar