En construcción…
Controlador ssd 1306 (Oled 0,96″)
DECLARACION DE VARIABLES
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled_1(128,64, &Wire,-1);
void setup(){
oled_1.begin(SSD1306_SWITCHCAPVCC,0x3C);//inicialización de pantalla en direccion 0x3c
oled_1.clearDisplay();
oled_1.display();
oled_1.setTextSize(1);
oled_1.setTextColor(WHITE);
oled_1.setCursor(25,32);//posición texto x,y
oled_1.print("TEST SSD1306");//escribir texto
oled_1.display();//envío a pantalla
}
Medidor de distancia HC-SR04
DECLARACION DE VARIABLES
#include <NewPing.h>
#define TRIGGER_PIN 12 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 11 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 100 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() {
Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}
void loop() {
delay(250); // Wait 250ms between pings (about 20 pings/sec). 29ms should be the shortest delay between pings.
Serial.print("Ping: ");
Serial.print(sonar.ping_cm()); // Send ping, get distance in cm and print result (0 = outside set distance range)
Serial.println("cm");
}
Pantalla de 2.8 Pulgadas 240×320 con controlador LCD SPI Serie ILI9341
DECLARACIÓN DE VARIABLES
#include "SPI.h"
#include "TFT_eSPI.h"
#define TFT_GREY 0x7BEF
TFT_eSPI tft = TFT_eSPI();
Void setup() {
tft.begin(); // inicializa pantalla
tft.setRotation(3); // establece posicion horizontal con pines derecha
}
void loop() {
tft.fillScreen(TFT_BLACK);//refresco de pantalla
touch = touchRead(touchpin);
tft.setTextColor(ILI9341_YELLOW);
tft.setCursor(90, 100);
tft.setTextSize(6);
tft.print(VARIABLE ELEGIDA);
delay(250);
}
Max7219
#include <SPI.h>
#include "LedMatrix.h"
#define NUMBER_OF_DEVICES 1
#define CS_PIN 5
LedMatrix ledMatrix = LedMatrix(NUMBER_OF_DEVICES, CS_PIN);
void setup() {
ledMatrix.init();
ledMatrix.setIntensity(2); // range is 0-15
ledMatrix.setText("Test");
}
void loop() {
ledMatrix.clear();
ledMatrix.oscillateText();
ledMatrix.drawText();
ledMatrix.commit();
delay(300);
}
Servos
#include <Servo.h>
Servo servo_15; // create servo object to control a servo
void setup() {
servo_15.attach(15); // attaches the servo on pin 11
servo_15.write(180);
analogSetPinAttenuation (36,ADC_11db);
}
void loop() {
int pos=analogRead(A0);
pos=map(pos,0,4095,0,180);
servo_15.write(pos);
delay(10);
}
WS2812B
Ejemplo con tira de 14 leds: Vaamos a encender la tira del 0 al 13 cada 250 ms, cuando llegue al final volvera a comenzar
#include <Adafruit_NeoPixel.h>
#define PIN 13
#define numleds 14
Adafruit_NeoPixel pixels(numleds, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pixels.begin();
}
void loop() {
int i=0;
while (i<14) {
i++;
pixels.setPixelColor(i, pixels.Color(25, 0,0));
pixels.show();
delay(25);
}
pixels.clear(); // Set all pixel colors to 'off'
pixels.show();
}