Skip to content

kuouu/victoria

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Victoria

Super cool PIC18F based LED lightsaber
Report Bug · Request Feature

Table of Contents

Usage

Wave Victoria, and when it exceeds a certain speed, the LED bulb will emit a smiley face (The Smile of the Goddess of Victory).

Devices&Environment

  • used hardware: PIC18F4520
  • compiler: XC 8

Circuit Diagram

image4

System Execution Process

image2

Interface&Library

  • GY-61 (ADXL-335)
  • LED lamp

Operation Principle

GY-61 has three analog pins: the accelerations in the directions of X-axis, Y-axis and Z-axis. The values are read into PIC18F4520 and then processed.

version 1

The first idea is to convert the vector to the current Victoria's tilt angle. The function library math.h is used here to convert the angle and side length, and atan2() is used to get the angle, and the range will be between -𝝅 and 𝝅. Images are stored in an array. Consider the distance between the light bulb and the center point as the longest side of the triangle, multiply sin() and cos() respectively to get the (x, y) coordinates of the array, and use this to draw the graph.

version 1 difficulty

When converting to (x, y) coordinates, you need to use the round() function to obtain integers, which will sacrifice the detection accuracy. In addition, because GY-61 itself has some errors in detection, it will flicker continuously at certain "border" angles, causing difficulties in image recognition.

version 2

Convert the current angle change to the corresponding element in the array. Assuming the current rotation degree is 0 degrees, the corresponding elements will be all the elements in the 0th column. If the current angle is 12 degrees, the corresponding elements in column 2 will be displayed. Therefore, as long as we input the angle of the lightsaber into the conversion formula and convert it into the number of columns corresponding to the array, we can know which LED should be turned on.

version 2 difficulty

Although the picture will be slightly distorted into a fan shape, you can roughly see the image's profile. But the sampling rate of GY-61 is too slow, it is difficult to get continuous angles, which results in broken pictures.

final version

Get the acceleration of the Z axis directly, and display the picture if it exceeds the threshold we set.

The image storage method is still using version 2, but the display method is to display one by one through __delay_ms() to achieve the effect of visual persistence.

About

PIC18F based LED lightsaber

Topics

Resources

Stars

Watchers

Forks

Languages