Giter Club home page Giter Club logo

r3-softwaretask1-nikolastrivanovic's Introduction

R3-SoftwareTask1-NikolasTrivanovic

Displayed above is a diagram of a circuit/system that translates the potentiometer position to a number between 0 and 99. The circuit consists of an arduino uno, 2 7-segment displays, 2 7-segment decoders and 1 potentiometer. A potentiometer is a variable resistor so the value being translated to the two 7-segment displays is the current resistance level (0 being minimum and 99 being maximum). In order to display the translated value mentioned previously 2 7-segment decoders are used to convert binary coded decimal (BCD) values to the desired digit on the display. These BCD values turn on specific segments of the display (A,B,C,D,E,F,G) creating the desired number. Ten different BCD values are used to represent the 10 possible digits, 0-9. The inputs of the decoders are connected to unused pins on the arduino from which a program can assign HIGH (1) and LOW (0) values to the decoder depending on the potentiometers position (resistance level).

When starting the task the first issue was mapping the potentiometer value. When the potentiometer is connected to the arduino through the analog input pin the resistance level (10bit number) was determined to range from 0 to 1023. When trying to manually turn the potentiometer with the mouse the value changed by around 20-21, eg 1023 ---> 1003 ---> 982 etc... Dividing the max value recorded from the potentiometer by the step size (20-21) gives the number of 2 digit values that can be smoothly represented. By smoothily represented I mean that every step or turn from the potentiometer changes the displayed value 1 digit at a time. For example 00,01,02,03,...,99 is smoothly transitioning but 99,97,95,93,....,0 is not. Given the step size of 20-21 and the max value being 1023 the highest 2 digit number you can display smoothly is roughly 1023/20.5 = 49.9 = 49.

After figuring out how to map the potentiometers the only step left was to seperate the 2 digit number (eg, 00, 12, 78) into it's respective ones column and tens column. By seperating these two columns the individual 7-segment display can be set with them. In order to determine the ones column of a 2 digit number you can take the modulo10 of that number. This is done because we are looking for the ones column and modulo gives the remainder after division, if we use modulo10 the remainder is the ones value that doesn't divide into 10 (eg, 9modulo10 = 0, 19modulo10 = 9). In order to find the tens column all we have to do is divide by 10 using the same logic previously mentioned.

Once the potentiometer value has been mapped and the ones and tens digits have been seperated we can loop through an array storing all the possible digits (0-9) with their respective BCD value (eg, 9 BCD=1001 ---> A(1),B(1),C(1),D(0),E(0),F(1),G(1)). Using these prestored BCD values we can set the output voltage (1=HIGH, 0=LOW) to the pins for the decoders to turn on the 7-segment displays (to the appropriate digit) as the potentiometer changes positions/values.

After finishing programming the logic for the circuit it can be clearly seen that setting the range to something below 50 results in every number from 1-49 being displayed with every turn of the potentiometer. Whereas when the range is set to 0-99 double the limit every other digit is show from 0-99, eg 99,97,95,93, etc...

The same logic can be applied to any number of digits being displayed. For example adding a third digit display requires seperating the translated digit into hunderds, tens and ones. However given the step size of the resistor (20-21) more numbers will be skipped in the display (ie 49 - every digit show, 99 - every other digit shown, 200 - every fourth digit shown etc...).

Below are six diagrams showing the difference between the range below 50 and above 50.

output-onlinepngtools (8) output-onlinepngtools (9) output-onlinepngtools (10)

output-onlinepngtools (11) output-onlinepngtools (12) output-onlinepngtools (13)

link to the TinkerCAD circuit simulation: https://www.tinkercad.com/things/0JJsqN7cakL-trainingtask1

r3-softwaretask1-nikolastrivanovic's People

Contributors

teorija 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.