Giter Site home page Giter Site logo

victoria's Introduction


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.

victoria's People

Contributors

kuouu avatar nahemah1022 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.