Paso 12: Show de luces laser código de control mental
copiar el bosquejo abajo y péguela en el IDE de Arduino verificar y ejecutar el programa.
Este dibujo fue creado usando código de adafruit y cerebro-bibliotecas
#define sclk 4
#define mosi 5
#define cs 6
#define dc 7
#define rst 8
Toma de tierra conectada a GND de Arduino
int Pin1 = 9; Conectado a 9 digital conectado a láser - in1
int Pin2 = 10; In2 conectado a 10 digital conectado al motor 2-
int Pin3 = 11; IN3 conectado a 11 digital conectado al motor 1-
int Pin4 = 12; In4 conectado a digital 12 no utilizado aquí
motor 1 y 2 + y laser + conectar al Arduino + 5v
#include < Adafruit_GFX.h > / / Biblioteca de gráficos de base
#include < Adafruit_ST7735.h > / / específicos de Hardware de biblioteca
#include < SPI.h >
#include < Brain.h >
Tft de Adafruit_ST7735 = Adafruit_ST7735 (cs, dc, mosi, sclk, rst);
Brain(Serial) del cerebro;
void setup(void) {}
tft.initR(INITR_BLACKTAB); inicializar una ficha de chip, negro ST7735S
pinMode (PIN 1, salida);
pinMode (Pin2, salida);
pinMode (Pin3, salida);
pinMode (Pin4, salida);
digitalWrite (PIN 1, 1);
digitalWrite (Pin2, 1);
digitalWrite (Pin3, 1);
digitalWrite (Pin4, 1);
tftPrintTest(); Texto de la introducción inicial,
Delay(1000);
tft.fillScreen(ST7735_BLACK); borrar la pantalla
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
tft.setCursor(30,0);
TFT.println ("Brain Control");
Serial.Begin(9600);
}
void loop() {}
Si (brain.update()) {}
Si (brain.readSignalQuality() > 199) {}
tft.fillScreen(ST7735_BLACK);
tft.setCursor(10,60);
tft.setTextSize(1);
tft.setTextColor(ST7735_RED,ST7735_BLACK);
TFT.println ("bajo cuadrado");
tft.fillScreen(ST7735_BLACK);
}
Else {}
tft.setCursor(30,0);
tft.setTextSize(1);
TFT.println ("Brain Control");
tft.drawLine (0, 20, (tft.width)-1, 20, ST7735_WHITE);
tft.drawLine (0, 130, tft.width ()-1, 130, ST7735_WHITE);
tft.setCursor (0, 30);
tft.setTextColor(ST7735_YELLOW,ST7735_BLACK);
tft.setTextSize(1);
TFT.Print ("calidad de la señal:");
TFT.Print(Brain.readSignalQuality());
TFT.println("");
TFT.println("");
tft.setTextColor(ST7735_CYAN,ST7735_BLACK);
TFT.println ("atención:");
tft.setTextSize(2);
tft.setCursor (60, 60);
TFT.Print(Brain.readAttention());
TFT.println("");
tft.setTextColor(ST7735_WHITE,ST7735_BLACK);
tft.setTextSize(1);
TFT.println("");
TFT.Print ("meditación:");
tft.setTextSize(2);
tft.setCursor (60, 100);
TFT.Print(Brain.readMeditation());
TFT.println("");
if(Brain.readSignalQuality() == 0) {}
tft.setCursor(0,140);
tft.setTextColor(ST7735_GREEN,ST7735_BLACK); establecer color para tiempo ON
tft.setTextSize (1); //set tamaño del texto
TFT.Print ("es a");
digitalWrite (PIN 1, 0);
}
Else {}
tft.setCursor(0,140);
tft.setTextColor(ST7735_RED,ST7735_BLACK); establecer color para tiempo ON
tft.setTextSize (1); //set tamaño del texto
TFT.Print ("láser está apagado");
digitalWrite (PIN 1, 1);
}
}
{} if(Brain.readAttention() > 5)
tft.setCursor(0,75);
tft.setTextColor(ST7735_GREEN,ST7735_BLACK); establecer color para tiempo ON
tft.setTextSize (1); //set tamaño del texto
TFT.Print ("MOTOR 2 está encendido");
analogWrite (Pin2, brain.readAttention());
}
Else {}
tft.setCursor(0,75);
tft.setTextColor(ST7735_RED,ST7735_BLACK); establecer color para tiempo ON
tft.setTextSize (1); //set tamaño del texto
TFT.Print ("MOTOR 2 está apagado");
digitalWrite (Pin2, 1);
}
{} if(Brain.readMeditation() > 5)
tft.setCursor(0,118);
tft.setTextColor(ST7735_GREEN,ST7735_BLACK); establecer color para tiempo ON
tft.setTextSize (1); //set tamaño del texto
TFT.Print ("MOTOR 1 está activada");
analogWrite (Pin3, brain.readMeditation());
}
Else {}
tft.setCursor(0,118);
tft.setTextColor(ST7735_RED,ST7735_BLACK); establecer color para tiempo ON
tft.setTextSize (1); //set tamaño del texto
TFT.Print ("MOTOR 1 está apagado");
digitalWrite (Pin3, 1);
}}}
void tftPrintTest() {}
tft.setTextWrap(false);
tft.fillScreen(ST7735_BLACK);
tft.setCursor (0, 10);
tft.setTextColor(ST7735_WHITE);
tft.setTextSize(1);
TFT.println ("
Delay(500);
tft.setCursor (30, 60);
tft.setTextColor(ST7735_RED);
tft.setTextSize(2);
TFT.println("Brain");
tft.setTextColor(ST7735_YELLOW);
tft.setCursor (5, 80);
TFT.println ("Controler");
tft.setTextColor(ST7735_BLUE);
Delay(50);
}