블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 받은 트랙백

글 보관함

calendar

  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      


Simple version of LED Light stand base for 3D crystal laser cube



I have Taj Mahal 3D crystal laser Cube.

You can get it from ebay also.





I found there are many stand bases for these kind of 3D crystal cube and it makes gorgeous view of it. like below.



So I've decided to develop it using Arduino.


The result is this.





This is the Source code.


/*

  For LED Light stand for 3D Crystal laser cube


  version : 0.4


  created 03 May 2017


  by Douglas Changsoo Park

*/


// Define Pins

#define RED1 3

#define GREEN1 4

#define BLUE1 5

#define RED2 6

#define GREEN2 7

#define BLUE2 8

#define delayTime 100


// define variables

int redValue1;

int greenValue1;

int blueValue1;

int redValue2;

int greenValue2;

int blueValue2;


void setup() {

  pinMode(RED1, OUTPUT);

  pinMode(GREEN1, OUTPUT);

  pinMode(BLUE1, OUTPUT);

  digitalWrite(RED1, HIGH);

  digitalWrite(GREEN1, HIGH);

  digitalWrite(BLUE1, HIGH);


  pinMode(RED2, OUTPUT);

  pinMode(GREEN2, OUTPUT);

  pinMode(BLUE2, OUTPUT);

  digitalWrite(RED2, HIGH);

  digitalWrite(GREEN2, HIGH);

  digitalWrite(BLUE2, HIGH);


  redValue1 = random(1, 255);

  greenValue1  = random(1, 255);

  blueValue1  = random(1, 255);

  redValue2 = random(1, 255);

  greenValue2  = random(1, 255);

  blueValue2  = random(1, 255);

}


void loop() {

  LEDLights(redValue1, greenValue1, blueValue1, redValue2, greenValue2, blueValue2);

  delay(delayTime * 4);

}


void LEDLights(int red1, int green1, int blue1, int red2, int green2, int blue2) {


  redValue1 = red1;

  greenValue1 = green1;

  blueValue1 = blue1;

  redValue2 = red2;

  greenValue2 = green2;

  blueValue2 = blue2;


  int redResult1 = randomValue(redValue1);

  int greenResult1 = randomValue(greenValue1);

  int blueResult1 = randomValue(blueValue1);


  int redResult2 = randomValue(redValue2);

  int greenResult2 = randomValue(greenValue2);

  int blueResult2 = randomValue(blueValue2);


  for (int i = 0; i < 25; i += 1) {

    analogWrite(RED1, redValue1 + redResult1);

    analogWrite(GREEN1, greenValue1 + greenResult1);

    analogWrite(BLUE1, blueValue1 + blueResult1);

    analogWrite(RED2, redValue2 + redResult2);

    analogWrite(GREEN2, greenValue2 + greenResult2);

    analogWrite(BLUE2, blueValue2 + blueResult2);


    redValue1 = redValue1 + redResult1;

    greenValue1 = greenValue1 + greenResult1;

    blueValue1 = blueValue1 + blueResult1;

    redValue2 = redValue2 + redResult2;

    greenValue2 = greenValue2 + greenResult2;

    blueValue2 = blueValue2 + blueResult2;


    delay(delayTime);

  }

}


int randomValue(int value) {

  int result;

  int minN;

  int maxN;


  int interval = random(1, 5);


  if (interval == 1) {

    minN = 26;

    maxN = 229;

  } else if (interval == 2) {

    minN = 51;

    maxN = 204;

  } else if (interval == 3) {

    minN = 76;

    maxN = 179;

  } else if (interval == 4) {

    minN = 101;

    maxN = 154;

  } else {

    minN = 126;

    maxN = 129;

  }


  if (value < minN) {

    result = interval;

  } else if (value > maxN) {

    result = -interval;

  } else {

    int randomVal = random(0, 1);

    if (randomVal == 0) {

      result = interval;

    } else {

      result = -interval;

    }

  }


  return result;

}




I wanted to make a combination and change of a more varied and softer color using random() in randomValue() function.


LEDLights() function will turn on and change the LED Light with the return value of the randomValue() function.


The loop() function will call the LED LIghts() function repeatedly every given time.


The components will be configured as below.





I've used Arduino Nano, 12V battery pack with 8 AAA batteries, 1 car charger adapter, small bread board and 2 RGB LEDs.


all parts are what I already have. 


It will cost about $ 15 for a new purchase.



Link to my project in hackster.


https://www.hackster.io/solkit/portable-led-light-stand-for-3d-crystal-laser-cube-5d8bd1








I don't like you

Practice scripting for the project 'I like you'


Source Code


/*

  For I don't like you. (practice project for the project 'I like you')


  version : 0.1


  created 07 May 2017


  by Douglas Changsoo Park

*/


#include <Servo.h>

#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 200 // 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.

Servo myservo;//create servo object to control a servo


int distance;


void setup() {

  myservo.attach(9);//attachs the servo on pin 9 to servo object

  myservo.write(0);//back to 0 degrees 

  delay(1000);//wait for a second


  Serial.begin(9600); // Open serial monitor at 115200 baud to see ping results.

}


void loop() {

  delay(500);  // 

  unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).

  Serial.print("Ping: ");

  Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)

  Serial.println("cm");

 

  distance = uS / US_ROUNDTRIP_CM;


  delay(500);

  // Servo motor moves when the distance is less than 5cm

  if (distance < 5 && distance != 0) {

    Serial.println("distance : ");

    Serial.println(distance); 

    myservo.write(90);//goes to 45 degrees 

    delay(500);

    myservo.write(-90);//goes to 45 degrees

    delay(500);

  }


}


==> Servo motor will move 90 degree and -90 degree when ultrasonic sensor detects object (person) in 5 cm.
Ultrasonic sonic sensor is going to be a pet's head so it looks like the pet is shaking his head because he doesn't like the person.

==> This is practice project of the project "I like you"
with the project, As you move, the pet will keep looking at you.
So the project name is "I like you" 

==> to do that I am planning to use 2 (or 3) ultrasonic sensor.

Anyway for the practice project "I don't like you", Arduino components should be configured as follows.



It will print the distance in 'cm' if it is run.




이전 1 다음