Alarm light

void setup() {
analogWrite(2, 255);
analogWrite(3, 255);
analogWrite(4, 255);
analogWrite(5, 255);
analogWrite(6, 255);
analogWrite(7, 255);
for(int i1 = 22; i1 <= 39; i1++) {
analogWrite(i1, 255);
}
delay(180000);
for(int i1 = 22; i1 <= 39; i1++) {
analogWrite(i1, 0);
}
for(int i = 255; i >= 0; i–) {
analogWrite(5, i);
delay(10);
analogWrite(6, i);
delay(10);
analogWrite(2, i);
delay(10);
analogWrite(3, i);
delay(10);
analogWrite(4, i);
delay(10);
}
analogWrite(7, 0);
delay(25200000); // 6 h = 21600000 ms; 7 h = 25200000 ms; 7,5 h = 27000000 ms; 8 h = 28800000 ms; 9 h = 32400000 ms;
for(int i = 0; i <= 255; i++) {
analogWrite(5, i);
delay(2000);
analogWrite(6, i);
delay(2000);
analogWrite(2, i);
delay(2000);
analogWrite(3, i);
delay(2000);
analogWrite(4, i);
delay(2000);
}
delay(900000);
}
void loop() {
analogWrite(7, 255);
analogWrite(2, 255);
delay(200);
analogWrite(2, 0);
delay(200);
analogWrite(3, 255);
delay(200);
analogWrite(3, 0);
delay(200);
analogWrite(4, 255);
delay(200);
analogWrite(4, 0);
delay(200);
analogWrite(5, 255);
delay(200);
analogWrite(5, 0);
delay(200);
analogWrite(6, 255);
analogWrite(7, 0);
delay(200);
analogWrite(6, 0);
delay(200);
for(int ii = 22; ii <= 39; ii++) {
analogWrite(ii, 0);
}
analogWrite(2, 255);
analogWrite(3, 255);
analogWrite(4, 255);
analogWrite(5, 255);
analogWrite(6, 255);
delay(200);
analogWrite(2, 0);
analogWrite(3, 0);
analogWrite(4, 0);
analogWrite(5, 0);
analogWrite(6, 0);
delay(200);
for(int ii = 22; ii <= 39; ii++) {
analogWrite(ii, 255);
}
}

Light controller with usb

Arduino code:

int led[18] = { 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39};
boolean juoksuledi = false;
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;
int heratys1 = false;
int heratys5 = false;
int pin = 2;
int brigt = 30;
int vol;
int vol1;
int vol2;
int vol3;
int x;
int y = 500;
int input;
int fade1;
long value3;
long value2;
long value1;
boolean ledit = false;
int mode = ‘a’;

long current_value3;
long current_value2;
long current_value1;
boolean music = false;
boolean power = false;
const int soundpin = A2; //reads the power from the light sensor
const int LED1= 22; //LED’s 1-6 numbered accordingly
const int LED2= 23;
const int LED3= 24;
const int LED4= 25;
const int LED5= 26;
const int LED6= 27; //LED’s 1-6 numbered accordingly
const int LED7= 28;
const int LED8= 29;
const int LED9= 30;
const int LED10= 31;
const int LED11= 32; //LED’s 1-6 numbered accordingly
const int LED12= 33;
const int LED13= 34;
const int LED14= 35;
const int LED15= 36;
const int LED16= 37; //LED’s 1-6 numbered accordingly
const int LED17= 38;
const int LED18= 39;
const int LED19= 40;
const int LED20= 41;
int sound[4];
int soundav;
int music1;
void setup() {
Serial.begin(9600);
pinMode(soundpin, INPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
pinMode(LED7, OUTPUT);
pinMode(LED8, OUTPUT);
pinMode(LED9, OUTPUT);
pinMode(LED10, OUTPUT);
pinMode(LED11, OUTPUT);
pinMode(LED12, OUTPUT);
pinMode(LED13, OUTPUT);
pinMode(LED14, OUTPUT);
pinMode(LED15, OUTPUT);
pinMode(LED16, OUTPUT);
pinMode(LED17, OUTPUT);
pinMode(LED18, OUTPUT);
pinMode(LED19, OUTPUT);
pinMode(LED20, OUTPUT);
randomSeed(analogRead(0));

value1 = random(255);
current_value1 = value1;
value2 = random(255);
current_value2 = value2;
value3 = random(255);
current_value3 = value3;

analogWrite(2, current_value1);
analogWrite(3, current_value2);
analogWrite(4, current_value3);

value1 = random(255);
value2 = random(255);
value3 = random(255);

}
void loop() {
input = Serial.read();
if(input == ‘h’) {
heratys5 = true;
}
if(heratys5 == true) {
heratys();
}

if(input == ‘0’) {
if(power == true) {
power = false;
delay(100);
}
else if(power == false){
power = true;
delay(100);
}
}
if(power == true) {
analogWrite(13, 255);
if(input == ‘l’) {
if(ledit == true) {
ledit = false;
}
else {
ledit = true;
}
}
if(ledit == true) {
if(input == ‘b’) {
if(mode == ‘a’) {
mode = ‘b’;
}
else {
mode = ‘a’;
}
}
if(mode == ‘a’) {
analogWrite(23, 0);
analogWrite(25, 0);
analogWrite(27, 0);
analogWrite(29, 0);
analogWrite(31, 0);
analogWrite(33, 0);
analogWrite(35, 0);
analogWrite(37, 0);
analogWrite(39, 0);
analogWrite(22, 255);
analogWrite(24, 255);
analogWrite(26, 255);
analogWrite(28, 255);
analogWrite(30, 255);
analogWrite(32, 255);
analogWrite(34, 255);
analogWrite(36, 255);
analogWrite(38, 255);
delay(500);
analogWrite(22, 0);
analogWrite(24, 0);
analogWrite(26, 0);
analogWrite(28, 0);
analogWrite(30, 0);
analogWrite(32, 0);
analogWrite(34, 0);
analogWrite(36, 0);
analogWrite(38, 0);
analogWrite(23, 255);
analogWrite(25, 255);
analogWrite(27, 255);
analogWrite(29, 255);
analogWrite(31, 255);
analogWrite(33, 255);
analogWrite(35, 255);
analogWrite(37, 255);
analogWrite(39, 255);
delay(500);
}
else {
for(int aa = 22; aa <= 39; aa++) {
analogWrite(aa, 255);
}
}
}
else {
for(int aa = 22; aa <= 39; aa++) {
analogWrite(aa, 0);
}
}
if(input == ‘j’) {
if(juoksuledi == true) {
juoksuledi == false;
}
else if(juoksuledi == false) {
juoksuledi = true;
}
}
if(input == ‘m’) {
if(music == true) {
music = false;
}
else if(music == false){
music = true;
}
}
if(input == ‘f’) {
if(fade1 == true) {
fade1 = false;
}
else if(fade1 == false){
fade1 = true;
}
}
if(fade1 == true) {
fader();
}
else {
if(input == ‘n’) {
if(music1 == true) {
music1 = false;
}
else if(music1 == false){
music1 = true;
}
}

if(music1 == true) {
musiccontrol();
}
else {
if(music == false) {
if(input == ‘1’) {
pin = pin + 1;
delay(500);
analogWrite(pin, brigt);
}
if(input == ‘2’) {
pin = pin – 1;
delay(500);
analogWrite(pin, brigt);
}
if(input == ‘3’) {
brigt = brigt + 1;
analogWrite(pin, brigt);
}
if(input == ‘4’) {
brigt = brigt – 1;
analogWrite(pin, brigt);
}
delayMicroseconds(100);
}
else {
vol = analogRead(A2);
vol1 = analogRead(A3);
if(input == ‘3’) {
x = x + 1;
}
if(input == ‘4’) {
x = x – 1;
}
if(input == ‘1’) {
y = y + 10;
}
if(input == ‘2’) {
y = y – 10;
}
vol2 = vol * x / 10;
vol3 = vol1 * x / 10;
if(vol2 <= vol3) {
analogWrite(4, vol3);
delay(10);
if(vol3 >= 100) {
for(int yy = 22; yy <= 30; yy++) {
analogWrite(yy, 255);
}
delay(10);
}
else {
for(int yy = 22; yy <= 30; yy++) {
analogWrite(yy, 0);
}
}
}
else {
analogWrite(4, 0);
}
if(vol3 <= vol2) {
analogWrite(2, vol2);
delay(10);
if(vol2 >= 100) {
for(int yy = 30; yy <= 39; yy++) {
analogWrite(yy, 255);
}
delay(10);
}
else {
for(int yy = 30; yy <= 39; yy++) {
analogWrite(yy, 0);
}
}
}
else {
analogWrite(2, 0);
}
if(vol2 + vol3 >= y) {
analogWrite(2, 255);
analogWrite(3, 255);
analogWrite(4, 255);
analogWrite(5, 255);
analogWrite(6, 255);
}
else {
analogWrite(3, 0);
analogWrite(5, 0);
analogWrite(6, 0);
}
}
}
}
}
else {
analogWrite(2, 0);
analogWrite(3, 0);
analogWrite(4, 0);
analogWrite(5, 0);
analogWrite(6, 0);
analogWrite(7, 0);
analogWrite(8, 0);
analogWrite(9, 0);
analogWrite(10, 0);
analogWrite(11, 0);
analogWrite(12, 0);
analogWrite(13, 0);
}

}
void musiccontrol() {
for(int num=0;num<4;num++)
{
input = Serial.read();
x = 4;
if(input == ‘4’) {
x = x + 1;
}
if(input == ‘3’) {
x = x – 1;
}
sound[num]=analogRead(soundpin) * 5 / x;
if(num==2)
{
soundav=(sound[0]+sound[1]+sound[2]+sound[3])/4;
if((soundav)>200)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, HIGH); // set the LED on
digitalWrite(LED15,HIGH);
digitalWrite(LED16,HIGH);
digitalWrite(LED17, HIGH); // set the LED on
digitalWrite(LED18,HIGH);
digitalWrite(LED19, HIGH); // set the LED on
digitalWrite(LED20,HIGH);
}
else if((soundav)>190)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, HIGH); // set the LED on
digitalWrite(LED15,HIGH);
digitalWrite(LED16,HIGH);
digitalWrite(LED17, HIGH); // set the LED on
digitalWrite(LED18,HIGH);
digitalWrite(LED19, HIGH); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>180)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, HIGH); // set the LED on
digitalWrite(LED15,HIGH);
digitalWrite(LED16,HIGH);
digitalWrite(LED17, HIGH); // set the LED on
digitalWrite(LED18,HIGH);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>170)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, HIGH); // set the LED on
digitalWrite(LED15,HIGH);
digitalWrite(LED16,HIGH);
digitalWrite(LED17, HIGH); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>160)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, HIGH); // set the LED on
digitalWrite(LED15,HIGH);
digitalWrite(LED16,HIGH);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>150)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, HIGH); // set the LED on
digitalWrite(LED15,HIGH);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>140)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, HIGH); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>130)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,HIGH);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>120)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, HIGH); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>110)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,HIGH);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>100)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,HIGH);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>90)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, HIGH); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>80)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,HIGH);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>70)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, HIGH); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>60)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,HIGH);
digitalWrite(LED7, LOW); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>50)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,HIGH);
digitalWrite(LED6,LOW);
digitalWrite(LED7, LOW); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>40)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, HIGH); // set the LED on
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7, LOW); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>30)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,HIGH);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7, LOW); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>20)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, HIGH); // set the LED on
digitalWrite(LED3,LOW);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7, LOW); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else if(soundav>10)
{
digitalWrite(LED1,HIGH);
digitalWrite(LED2, LOW); // set the LED on
digitalWrite(LED3,LOW);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7, LOW); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);
}
else
{
digitalWrite(LED1,LOW);
digitalWrite(LED2, LOW); // set the LED on
digitalWrite(LED3,LOW);
digitalWrite(LED4, LOW); // set the LED on
digitalWrite(LED5,LOW);
digitalWrite(LED6,LOW);
digitalWrite(LED7, LOW); // set the LED on
digitalWrite(LED8,LOW);
digitalWrite(LED9, LOW); // set the LED on
digitalWrite(LED10,LOW);
digitalWrite(LED11,LOW);
digitalWrite(LED12, LOW); // set the LED on
digitalWrite(LED13,LOW);
digitalWrite(LED14, LOW); // set the LED on
digitalWrite(LED15,LOW);
digitalWrite(LED16,LOW);
digitalWrite(LED17, LOW); // set the LED on
digitalWrite(LED18,LOW);
digitalWrite(LED19, LOW); // set the LED on
digitalWrite(LED20,LOW);

}
}
}
delay(10);
}
void heratys() {
Serial.println(“HERATYS”);
int inLetter;
if(Serial.read() >= 0)
{
Serial.println(“HERATYS1”);

inLetter = Serial.read();
char buffer[] = {‘ ‘,’ ‘,’ ‘,’ ‘}; // Receive up to 8 bytes
while(!Serial.available());
Serial.readBytesUntil(‘\n’, buffer, 4);
int incomingValue = atoi(buffer);
Serial.println(“min:”);
Serial.println(incomingValue);
Serial.println(“ms:”);
int aika = incomingValue;
aika = aika * 60;
aika = aika * 1000;
Serial.println(aika);
delay(aika);
heratys1 = true;
}
if(heratys1 == true) {
analogWrite(5, 255);
delay(100);
analogWrite(5, 0);
delay(100);
analogWrite(5, 255);
delay(100);
analogWrite(5, 0);
delay(100);
analogWrite(5, 255);
delay(100);
analogWrite(5, 0);
delay(100);
}
}
void fader() {

if (value1 > current_value1){

current_value1++;
analogWrite(2, current_value1);
x = random(1000);
delayMicroseconds(x);
}

if (value1 < current_value1){

current_value1–;
analogWrite(2, current_value1);
x = random(10000);
delayMicroseconds(x);

}

if (value1 == current_value1){

analogWrite(2, current_value1);
x = random(10000);
value1 = random(255);

}

//////////////////////////

if (value2 > current_value2){

current_value2++;
analogWrite(3, current_value2);
x = random(1000);
delayMicroseconds(x);
}

if (value2 < current_value2){

current_value2–;
analogWrite(3, current_value2);
x = random(10000);
delayMicroseconds(x);

}

if (value2 == current_value2){

analogWrite(3, current_value2);
value2 = random(255);

}

 

///////////////////////////////

 

if (value3 > current_value3){

current_value3++;
analogWrite(4, current_value3);
x = random(10000);
delayMicroseconds(x);
}

if (value3 < current_value3){

current_value3–;
analogWrite(4, current_value3);
x = random(1000);
delayMicroseconds(x);

}

if (value3 == current_value3){

analogWrite(4, current_value3);
value3 = random(255);

}
}

 

Visual Basic code (you need one textbox named txt1.Text and one button named Button1):

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

SendSerialData(txt1.Text) ‘this here send whats inside a text box to Com4 and Arduino gets it all just fine

End Sub

Sub SendSerialData(ByVal data As String) ‘this is the function that is sending my data from VB to Arduino

Using com4 As IO.Ports.SerialPort =
My.Computer.Ports.OpenSerialPort(“COM4”)
com4.WriteLine(data)

End Using
End Sub

 

 

Projektini

Hei kaikki!

Täällä blogissa kerron arduino projekteistani ja voin antaa ohjeita muille niitä tarvitseville. Olen itsekin vielä aloittelija ja tarvitsen paljon apua, mutta toivon, että minäkin voin auttaa teitä lukijoita pulmissanne.

Elias Ojala