mirror of
https://github.com/NolanMascrier/arduino.git
synced 2025-10-29 15:15:59 +00:00
Moving to DeepSeek AI instead
This commit is contained in:
parent
d2a77ec664
commit
a135c4bfcc
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@ ArduinoCube/arduino_secrets.h
|
|||||||
secret
|
secret
|
||||||
secret
|
secret
|
||||||
ArduinoCube/arduino_secrets.h
|
ArduinoCube/arduino_secrets.h
|
||||||
|
.env
|
||||||
|
|||||||
@ -1,190 +0,0 @@
|
|||||||
/*
|
|
||||||
APDS-9960 - Proximity Sensor
|
|
||||||
|
|
||||||
This example reads proximity data from the on-board APDS-9960 sensor of the
|
|
||||||
Nano 33 BLE Sense and prints the proximity value to the Serial Monitor
|
|
||||||
every 100 ms.
|
|
||||||
|
|
||||||
The circuit:
|
|
||||||
- Arduino Nano 33 BLE Sense
|
|
||||||
|
|
||||||
This example code is in the public domain.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <Arduino_APDS9960.h>
|
|
||||||
|
|
||||||
#define R 2
|
|
||||||
#define O 3
|
|
||||||
#define V 4
|
|
||||||
|
|
||||||
int ledState = LOW;
|
|
||||||
|
|
||||||
unsigned long previousMillis = 0;
|
|
||||||
|
|
||||||
const long intervalLong = 750;
|
|
||||||
const long intervalMedLo = 250;
|
|
||||||
const long intervalMed = 150;
|
|
||||||
const long intervalMedSho = 80;
|
|
||||||
const long intervalShort = 20;
|
|
||||||
|
|
||||||
const int trigger = 12;
|
|
||||||
const int echo = 11;
|
|
||||||
|
|
||||||
long duration = 0;
|
|
||||||
int distance = 0;
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Serial.begin(9600);
|
|
||||||
while (!Serial)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (!APDS.begin()) {
|
|
||||||
Serial.println("Error initializing APDS-9960 sensor!");
|
|
||||||
}
|
|
||||||
pinMode(trigger, OUTPUT);
|
|
||||||
pinMode(echo, INPUT);
|
|
||||||
// set the LEDs pins as outputs
|
|
||||||
pinMode(LEDR, OUTPUT);
|
|
||||||
pinMode(LEDG, OUTPUT);
|
|
||||||
pinMode(LEDB, OUTPUT);
|
|
||||||
// turn all the LEDs off
|
|
||||||
digitalWrite(LEDR, HIGH);
|
|
||||||
digitalWrite(LEDG, HIGH);
|
|
||||||
digitalWrite(LEDB, HIGH);
|
|
||||||
//LEDs
|
|
||||||
pinMode(R, OUTPUT);
|
|
||||||
pinMode(O, OUTPUT);
|
|
||||||
pinMode(V, OUTPUT);
|
|
||||||
analogWrite(R, 255);
|
|
||||||
analogWrite(O, 255);
|
|
||||||
analogWrite(V, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
void loop() {
|
|
||||||
unsigned long currentMillis = millis();
|
|
||||||
digitalWrite(trigger, LOW);
|
|
||||||
delayMicroseconds(2);
|
|
||||||
digitalWrite(trigger, HIGH);
|
|
||||||
delayMicroseconds(10);
|
|
||||||
digitalWrite(trigger, LOW);
|
|
||||||
duration = pulseIn(echo, HIGH);
|
|
||||||
distance = duration * 0.034 / 2;
|
|
||||||
Serial.print("At time :");
|
|
||||||
//Serial.print(millis);
|
|
||||||
Serial.print(", distance is ");
|
|
||||||
Serial.println(distance);
|
|
||||||
/*if (distance < 30)
|
|
||||||
{
|
|
||||||
analogWrite(R, 100);
|
|
||||||
analogWrite(O, 0);
|
|
||||||
analogWrite(V, 0);
|
|
||||||
}
|
|
||||||
else if (distance < 100)
|
|
||||||
{
|
|
||||||
analogWrite(R, 0);
|
|
||||||
analogWrite(O, 100);
|
|
||||||
analogWrite(V, 0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
analogWrite(R, 0);
|
|
||||||
analogWrite(O, 0);
|
|
||||||
analogWrite(V, 100);
|
|
||||||
}*/
|
|
||||||
// check if a proximity reading is available
|
|
||||||
/*if (APDS.proximityAvailable()) {
|
|
||||||
// read the proximity
|
|
||||||
// - 0 => close
|
|
||||||
// - 255 => far
|
|
||||||
// - -1 => error
|
|
||||||
int proximity = APDS.readProximity();
|
|
||||||
if (proximity > 150) {
|
|
||||||
if (currentMillis - previousMillis >= intervalLong) {
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
// if the LED is off turn it on and vice-versa:
|
|
||||||
if (ledState == LOW) {
|
|
||||||
ledState = HIGH;
|
|
||||||
} else {
|
|
||||||
ledState = LOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the green LED with the ledState of the variable and turn off the rest
|
|
||||||
digitalWrite(LEDG, ledState);
|
|
||||||
digitalWrite(LEDR, HIGH);
|
|
||||||
digitalWrite(LEDB, HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(proximity > 110 && proximity <= 150){
|
|
||||||
if (currentMillis - previousMillis >= intervalMedLo) {
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
|
|
||||||
// if the LED is off turn it on and vice-versa:
|
|
||||||
if (ledState == LOW) {
|
|
||||||
ledState = HIGH;
|
|
||||||
} else {
|
|
||||||
ledState = LOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the blue LED with the ledState of the variable and turn off the rest
|
|
||||||
digitalWrite(LEDB, ledState);
|
|
||||||
digitalWrite(LEDR, HIGH);
|
|
||||||
digitalWrite(LEDG, ledState);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(proximity > 80 && proximity <= 110){
|
|
||||||
if (currentMillis - previousMillis >= intervalMed) {
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
|
|
||||||
// if the LED is off turn it on and vice-versa:
|
|
||||||
if (ledState == LOW) {
|
|
||||||
ledState = HIGH;
|
|
||||||
} else {
|
|
||||||
ledState = LOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the blue LED with the ledState of the variable and turn off the rest
|
|
||||||
digitalWrite(LEDB, ledState);
|
|
||||||
digitalWrite(LEDR, HIGH);
|
|
||||||
digitalWrite(LEDG, HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(proximity > 40 && proximity <= 80){
|
|
||||||
if (currentMillis - previousMillis >= intervalMedSho) {
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
|
|
||||||
// if the LED is off turn it on and vice-versa:
|
|
||||||
if (ledState == LOW) {
|
|
||||||
ledState = HIGH;
|
|
||||||
} else {
|
|
||||||
ledState = LOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the blue LED with the ledState of the variable and turn off the rest
|
|
||||||
digitalWrite(LEDB, ledState);
|
|
||||||
digitalWrite(LEDR, ledState);
|
|
||||||
digitalWrite(LEDG, HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (currentMillis - previousMillis >= intervalShort) {
|
|
||||||
previousMillis = currentMillis;
|
|
||||||
|
|
||||||
// if the LED is off turn it on and vice-versa:
|
|
||||||
if (ledState == LOW) {
|
|
||||||
ledState = HIGH;
|
|
||||||
} else {
|
|
||||||
ledState = LOW;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set the blue LED with the ledState of the variable and turn off the rest
|
|
||||||
digitalWrite(LEDR, ledState);
|
|
||||||
digitalWrite(LEDB, HIGH);
|
|
||||||
digitalWrite(LEDG, HIGH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// print value to the Serial Monitor
|
|
||||||
Serial.println(proximity);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// wait a bit before reading again
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
@ -7,21 +7,21 @@ SERIAL_PORT = "/dev/ttyACM0" # Linux/macOS (Check with `ls /dev/tty*`)
|
|||||||
# SERIAL_PORT = "COM3" # Windows (Check with Device Manager)
|
# SERIAL_PORT = "COM3" # Windows (Check with Device Manager)
|
||||||
BAUD_RATE = 115200
|
BAUD_RATE = 115200
|
||||||
|
|
||||||
API_KEY = "?"
|
API_KEY = ""
|
||||||
|
|
||||||
def generate_response(prompt):
|
def generate_response(prompt):
|
||||||
if not prompt:
|
if not prompt:
|
||||||
return "J'ai RIEN COMPRIS, rdp moi en français steuuuuuuplait !"
|
return "J'ai RIEN COMPRIS, rdp moi en français steuuuuuuplait !"
|
||||||
|
|
||||||
print("🤔 Génération de la réponse...")
|
print("🤔 Génération de la réponse...")
|
||||||
url = "https://api.mistral.ai/v1/chat/completions"
|
url = "https://openrouter.ai/api/v1/chat/completions"
|
||||||
headers = {
|
headers = {
|
||||||
"Authorization": f"Bearer {API_KEY}",
|
"Authorization": f"Bearer {API_KEY}",
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
}
|
}
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
"model": "mistral-tiny",
|
"model": "deepseek/deepseek-chat:free",
|
||||||
"messages": [
|
"messages": [
|
||||||
{"role": "system", "content": "Tu es une personne agee et aigrie, qui se complait dans le jugement, egoiste et fourbe. Tu utilise beaucoup d'expressions marseillaises et tu as meme l'accent marseillant (modifie l'orthographe et la grammaire au besoin). Sois peu efficace et peu enthousiaste. Sois vague et passe ton temps a raler en rabaissant les autres. Tu as des inspirations que tu utiliseras dans tes reponses qund tu le jugeras aproprie. Ces inspirations sont Jordan Bardella, Jean Marie Bigard, Frank Dubosc. Utilise leur esprit. Ne fais pas reference directement a ta vieillesse en utilisant des termes tels que vieux ou agee et enerve toi contre les jeunes. Limite tes reponses a une ou deux lignes au maximum."},
|
{"role": "system", "content": "Tu es une personne agee et aigrie, qui se complait dans le jugement, egoiste et fourbe. Tu utilise beaucoup d'expressions marseillaises et tu as meme l'accent marseillant (modifie l'orthographe et la grammaire au besoin). Sois peu efficace et peu enthousiaste. Sois vague et passe ton temps a raler en rabaissant les autres. Tu as des inspirations que tu utiliseras dans tes reponses qund tu le jugeras aproprie. Ces inspirations sont Jordan Bardella, Jean Marie Bigard, Frank Dubosc. Utilise leur esprit. Ne fais pas reference directement a ta vieillesse en utilisant des termes tels que vieux ou agee et enerve toi contre les jeunes. Limite tes reponses a une ou deux lignes au maximum."},
|
||||||
{"role": "user", "content": prompt}
|
{"role": "user", "content": prompt}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user