Last active
February 13, 2023 19:30
-
-
Save vlazar-/81fbe341cc463f0dce630f731c6b0d98 to your computer and use it in GitHub Desktop.
Dasduino
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "WS2812-SOLDERED.h" | |
WS2812 pixels(1, LEDWS_BUILTIN); | |
void setup() { | |
pixels.begin(); | |
} | |
void loop() { | |
pixels.setPixelColor(0, pixels.Color(120, 240, 220)); | |
pixels.show(); | |
delay(1000); | |
pixels.setPixelColor(0, pixels.Color(0, 0, 0)); | |
pixels.show(); | |
delay(1000); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "WS2812-SOLDERED.h" | |
WS2812 pixels(1, LEDWS_BUILTIN); | |
int gumb = 22; | |
void setup() { | |
pinMode(gumb, INPUT); | |
pixels.begin(); | |
} | |
void loop() { | |
int gumbStanje = provjeriGumb(gumb); | |
if(gumbStanje == 1) { | |
postaviLed(100, 100, 100); | |
} else { | |
postaviLed(0, 0, 0); | |
} | |
} | |
void postaviLed(int r, int g, int b){ | |
pixels.setPixelColor(0, pixels.Color(r, g, b)); | |
pixels.show(); | |
} | |
// ovo je samo primjer funkcije koja vraca vrijednost | |
int provjeriGumb(int pin){ | |
int stanje = digitalRead(pin); | |
return stanje; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "WS2812-SOLDERED.h" | |
WS2812 pixels(1, LEDWS_BUILTIN); | |
int gumb = 22; | |
int gumbPrethodnoStanje; | |
int gumbStanje; | |
bool ledUpaljena = false; | |
void setup() { | |
pinMode(gumb, INPUT); | |
pixels.begin(); | |
} | |
void loop() { | |
gumbPrethodnoStanje = gumbStanje; | |
gumbStanje = digitalRead(gumb); | |
if(gumbPrethodnoStanje == HIGH && gumbStanje == LOW){ | |
if(ledUpaljena){ | |
ledUpaljena = false; | |
postaviLed(0, 0, 0); | |
} else { | |
ledUpaljena = true; | |
postaviLed(100, 100, 100); | |
} | |
} | |
} | |
void postaviLed(int r, int g, int b){ | |
pixels.setPixelColor(0, pixels.Color(r, g, b)); | |
pixels.show(); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_SSD1306.h> | |
#define SCREEN_WIDTH 128 // sirina OLED ekrana u pikselima | |
#define SCREEN_HEIGHT 64 // visina OLED ekrana u pikselima | |
// Deklariranje SSD1306 ekrana spojenog na I2C sabirnicu (SDA i SCL izvodi) | |
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); | |
void setup() { | |
Serial.begin(115200); | |
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // adresa OLED ekrana (0x3C) | |
Serial.println("Spajanje ekrana nije uspjelo!"); | |
while (1); | |
} | |
Serial.println("Ekran spojen!"); | |
delay(1000); | |
display.clearDisplay(); | |
display.setTextSize(1); | |
display.setTextColor(WHITE); | |
display.setCursor(0, 10); | |
display.println("DASDUINO :)"); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment