CrazyEngineers
  • Okay im a newbie to Microcontrollers so dont yell at me too loud. I have a project I am working on. Basically I need to use 5 switches to act like 10. here are my thoughts of how I want it to work and someone tell me if a microcontroller can do this.. Then I will start studying micros..

    I have 5 momentary switches.. Lets say Pushbuttons. How they connect to the microcontroller isnt important to me- Shorting 2 inputs together or shorting an input to ground when the button is pressed are both acceptable.

    The outputs need to short 2 connection points together (Hopefully without relays) so lets say by pressing the button on input#1, I want outputs# 1 and 2 to short together.

    That would be the first question- can the controller do that???


    Now IF the controller can do that we can move on. Lets simplify the idea by sayign the circuit has 1 pushbutton (input) and 4 ouput wires. lets see if I can draw it:

    Okay picture didnt work- Imagine 1 or 2 wire input and 4 wire outputs (numbered 1-4)

    Okay so "in1" and "in2" are connected to the momentary Push button. Pushing the button shorts them together.

    When I briefly press the pushbutton, I want the micro to short outputs 1 and 2 together for 1 second

    When I press the pushbutton quickly twice (press for one second, release, press again for one second) I want the micro to short outputs 3 and 4 together for 1 second

    BUT if I press and hold the pushbutton for more then 3 seconds, I want the micro to short outputs 1 and 2 together for 3 second.


    Does that make sense? So if all that can work, then I will have 5 pushbuttons, and 20 output lines. Is that possible?

    Timing isnt super sensetive so changes can be made to that. I can use more than one Micro if needed. I really dont want to use relays if possible... cuz I would need 10 of them😔

    Im not asking someone to design this for me (Although I wont stop you ;-)). What I really need to know is if its possible or am I barking up the wrong tree?

    Thanks everyone!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • xheavenlyx

    MemberSep 25, 2007

    OOOOhh GOD! I just realized ur Q!! Anyway I had written all this below without reading it properly and anyway, it was a little confusing...so skip this in QUOTES if you find it toooo basic!

    Dont worry, this is the first new-member post I have seen with the best formation of Q! So you will get plenty of help 😀

    Anyway the first thing I want to clear is there are 2 ways of treating your inputs and outputs(inps/outps).

    One is that you can configure which pins can act as what. Like if you have total 20 I/O lines in a Microcontroler (uC) then you can configure them in anyway u like, you can have one input and 19 outp or even 10 inp and 10 outp. this is done thru programming the uC. Some uC's can be programed like this but some cant. Check which uC you will use with how many lines!

    Ok now after that, assuming you just have 2 inp lines and 2 out (total 4) then you DONT need to tie up the 2 inp to make one switch!!! You have to do it like so:

     5V-----_'(switch)------>input 1 of uC
    5v-----_'(switch)------>input 2 of uC
    so you have 2 inputs to the uC!

    and as for the output. I will show with LEDs:

     --->(out1)---->|(led)-----(ground)
    --->(out2)---->|(led)-----(ground)
    You can do the same by going advance and how you have suggested above. Tie together two pinouts and configure one to send power, and the other to ground....but that will waste your outputs!!! And why the hell wud you want to short 2 outputs?? lol, just use the above diagram, and you know this...to connect what ever u like.

    Anyway, do no connect led or anything directly to the outputs, you need to add a resistance. Guess u know that too..

    ===========Now for the problem of 10 outputs==============


    Ok, here is the part after looking at your Q from some other direction...I will reconstruct the problem and try to understand it better:

    you have a car remote control, and you want to short those inputs to act as a switch for the cars 2 controls, front/back and right/left.

    Well, as you said relays can be used but they are too bulky, anyway, you CANNOT and SHOULDNOT short those switches like so! Your microcontroller cannot provide power to whatever you are trying to switch on EVEN if that device has its own power source (like 9V in car remote control)...


    SO, you could use a transistor as a switch, a simple one. Thats how most switches are used... NOW, as in the case of getting 20 OUTPUTS, you will have to use a decoder:

    [​IMG]

    This IC can come in any form, but I suggest using a 3to8 decoder. This will convert your binary input from 3 lines into one of the 8 outputs. You can use 2 of these to get 16 outputs PLUS your remaining outputs from a micro.

    You can also make all of this using only one switch and make it act like a morse code input.

    IF YOU GOT JUST ONE INPUT SWITCH INTO MICROc:

    one click: OUT1
    one click one click: OUT2
    one click one click longer than 500ms: OUT3
    one click one click one click longer than 500ms: OUT4
    one click of 500ms: OUT5...blah blah and so on...

    tell me if you understood any of my blabber or if I got your Q right!
    Are you sure? This action cannot be undone.
    Cancel
  • Ashraf HZ

    MemberSep 26, 2007

    Haha, I knew xheavenlyx would reply sooner or later. This project of yours seems interesting, whoknows. Welcome to the world of uC 😉
    Are you sure? This action cannot be undone.
    Cancel
  • whoknows

    MemberSep 26, 2007

    Wow! Thanks for all that xheavenlyx!!

    You are close on what I am using this for. It is for a car radio. The reason I want to short the outputs is this: I have 10 momentary pushbuttons on the face of my radio, I am putting the radio into a custom housing which only has space for 5 momentary pushbuttons. This is why I want to short the outputs together. That is simplest way for hook up.

    Your info got me to thinking. The radio is using a microcontroler to control all the functions of the pushbuttons... If I am not so stupid I should check if closing one of the pushbuttons is providing a ground or 5V.. then maybe I dont need to short the contacts together. I shoudl check that😒

    Thank You for the basic info on the microcontroller. It is very helpful.

    Here is one additional question. Can a microcontroller be programmed to supply a dierent voltage out of the output... maybe 3volts instead of 5volts? or is it always 5 volts?

    Thanks again for the info!!!!!!!!!!!!!!!!!!!!
    Are you sure? This action cannot be undone.
    Cancel
  • whoknows

    MemberSep 26, 2007

    Okay- I checked out the schematic of the radio I wanted to use. Im really embarassed to admit this but all the butons short ground to one of 4 bus lines through different resistors. 😒😒

    So the good news is that the microcontroller will work. Now its study time. I have to figure out which chip to use and how to configure it. Sounds like fun.

    Wish me luck😁😁
    Are you sure? This action cannot be undone.
    Cancel
  • xheavenlyx

    MemberSep 27, 2007

    Its nice to know I could help you here 😀

    Here is one additional question. Can a microcontroller be programmed to supply a dierent voltage out of the output... maybe 3volts instead of 5volts? or is it always 5 volts?
    Well, the main thing to keep in mind is that, usually microC are not used to power up things or run equipments. you have to use a mC as a switching device or a programed/timed event thingy.

    so what you can do is use that circuit i suggested with a transistor. Instead of having a seperate supply of 5V or 9V to the transistor have one of 3V (1.5+1.5) but that needs some calculations and Id suggest refering your professor for it 😀 cuz it can get a little involving and typing the explaination can be a headache! (even tough to read). BUT If I get a diagram drawn then Ill give it 😀

    and yea Please,,, your project sounds very interesting so please give a detailed explanation step by step of it so maybe we can help a bit more.
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register