Tags » Arduino

Introduzione Arduino

Saluti amici. ¬†Benvenuti nel mondo della tecnologia. ¬†Tonight TechnologyNEducation is featuring a software/hardware combination that is sure to be a hit in any Physics, Engineering, or Technology classroom; the… 367 more words

Education

Update on CW Decoder

Received the 4×20 (4 lines, 20 characters per line) LCDs. This made using the CW Decoder so much more enjoyable to use. I changed the code a bit to put the WPM rate and my call sign on the first line and then three lines of cw. 89 more words

Projects

Evaluation

Working in iterations has helped me and my workflow significantly. By starting off Iteration 1 with research and exploration into the space we would be displaying in – The Foyer of Weymouth House. 1,143 more words

Design Iterations

Pulsating LED

Circuit Setup

int ledPin = 11;
float sinVal;
int ledVal;

void setup(){
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop(){

  for (int x = 0; x < 180; x++){
    sinVal = (sin(x * (3.1414/180)));
    ledVal = int(sinVal * 255);
    analogWrite(ledPin, ledVal);
    delay(25);
  }
}
Arduino

Serial Input LED Mood Lamp

Circuit Setup

char buffer;
int red, green, blue;

int RedPin = 11;
int GreenPin = 10;
int BluePin = 9;

void setup(){

  Serial.begin(9600);
  while(Serial.available()) Serial.read();
  pinMode(RedPin, OUTPUT);
  pinMode(GreenPin, OUTPUT);
  pinMode(BluePin, OUTPUT);
}

void loop(){

  if(Serial.available() > 0){
    int index = 0;
    delay(100);
    int numChar = Serial.available();
    if(numChar > 15){
      numChar=15;
    }
    while(numChar--){
      buffer = Serial.read();
    }
    splitString(buffer);
  }
}

void splitString(char* data){
  Serial.print("Data entered: ");
  Serial.println(data);
  char* parameter;
  parameter = strtok(data, " ,");
  while(parameter != NULL){
    setLED(parameter);
    parameter = strtok(NULL, " ,");
  }
  for(int x = 0; x < 16; x++){
    buffer[x]='';
  }
  while(Serial.available()) Serial.read();
}

void setLED(char* data){

  if((data[0] == 'r') || (data[0] == 'R')){
    int Ans = strtol(data+1, NULL, 10);
    Ans = constrain(Ans, 0, 255);
    analogWrite(RedPin, Ans);
    Serial.print("Red is set to: ");
    Serial.println(Ans);
  }
  
  if((data[0] == 'g') || (data[0] == 'G')){
    int Ans = strtol(data + 1, NULL, 10);
    Ans = constrain(Ans,0,255);
    analogWrite(GreenPin, Ans);
    Serial.print("Green is set to: ");
    Serial.println(Ans);
  }
  if((data[0] == 'b') || (data[0] == 'B')){
    int Ans = strtol(data+1, NULL, 10);
    Ans = constrain(Ans,0,255);
    analogWrite(BluePin, Ans);
    Serial.print("Blue is set to: ");
    Serial.println(Ans);
  }
}
Arduino

LED Mood Lamp

Circuit Setup

float rgb1[3];
float rgb2[3];
float inc[3];

int red, green, blue;

int RedPin = 11;
int GreenPin = 10;
int BluePin = 9;

void setup(){
  Serial.begin(9600);
  randomSeed(analogRead(0));

  rgb1[0] = 0;
  rgb1[1] = 0;
  rgb1[2] = 0;
  
  rgb2[0] = random(256);
  rgb2[1] = random(256);
  rgb2[2] = random(256);
}

void loop(){
  randomSeed(analogRead(0));
  
  for(int x = 0; x < 3; x++){
    inc[x] = (rgb1[x] - rgb2[x]) / 256;
  }
  
  for(int x = 0; x < 256; x++){
    red = int(rgb1[0]);
    green = int(rgb1[1]);
    blue = int(rgb1[2]);
    
    analogWrite(RedPin, red);
    analogWrite(GreenPin, green);
    analogWrite(BluePin, blue);
    delay(100);
    
    rgb1[0] -= inc[0];
    rgb1[1] -= inc[1];
    rgb1[2] -= inc[2];
  }
  for(int x = 0; x < 3; x++){
    rgb2[x] = random(556) - 300;
    rgb2[x] = constrain(rgb2[x], 0, 255);
    delay(1000);
  }
  
}
Arduino

LED SOS

Circuit Setup

int ledPin = 10;

void setup(){
  pinMode(ledPin, OUTPUT);
}

void loop(){
  // 3 dots
  for (int x = 0; x < 3; x++){
    digitalWrite(ledPin, HIGH);
    delay(150);
    digitalWrite(ledPin, LOW);
    delay(100);
  }
  
  delay(100);
  
  // 3 dash
  for(int x = 0; x < 3; x++){
    digitalWrite(ledPin, HIGH);
    delay(400);
    digitalWrite(ledPin, LOW);
    delay(400);
  }
  
  delay(100);
  
  // 3 dots
  for (int x = 0; x < 3; x++){
    digitalWrite(ledPin, HIGH);
    delay(150);
    digitalWrite(ledPin, LOW);
    delay(100);
  }
  
  delay(5000);
}
Arduino