element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino
  • Products
  • More
Arduino
Arduino Forum ATtiny45 with arduino
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Verified Answer
  • Replies 8 replies
  • Answers 2 answers
  • Subscribers 404 subscribers
  • Views 893 views
  • Users 0 members are here
  • pin
  • buttons
  • controller
  • ardunio
  • pwm
  • many
  • single
Related

ATtiny45 with arduino

dirtdiver
dirtdiver over 13 years ago

I was wondering how to controll 3 switches with one PWM pin,

what i had in mind was : hooking up the analog pin from the ATtiny to the Digital PWM pin from the arduino, and have a code like this:

if I send ...say 100 to the PWM pin , and i receive that value at the Attiny's analog pin and have it to do this :

If (analogRead == 100){

 

digitalWrite (Pin6 *from the Attiny* , HIGH)

}

 

then i send a 150 from the arduino and have it turn the other switch on , and in theory i should be able to control a few buttons with a single PWM pin from the arduino , is that really possible?

Thanks

  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 13 years ago in reply to dirtdiver +1 suggested
    If your going to do that then why not use an IR emitter and receiver.
Parents
  • billabott
    0 billabott over 13 years ago

    Why not use  I2C for your communication between the two microprocessors?

    This link might be helpful.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • dirtdiver
    0 dirtdiver over 13 years ago in reply to billabott

    That is verry interesting and i will definitely look at it , but with the time i have i wont be able to study it and complete my other project in time ,

    I , however just came up with another simple idea to use one digital PWM pin to send different values to the analog input of the Attiny

    Heres a visual example :

     

       image

    It wont be with a geat accuracy but i only need 3 values and i think thats achievable

    Plus with this i dont need filters and stuff

    What do you guys think, it has to work.(I am still waiting for the attiny to arrive and i cant test it...)

    And thank you all for the suggestions

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 13 years ago in reply to dirtdiver

    If your going to do that then why not use an IR emitter and receiver.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • dirtdiver
    0 dirtdiver over 13 years ago in reply to Former Member

    The code is much simpler, at least for me, Im not sure what the code will look like for the IR emitter and receiver.And what is the difference?I mean im not fully familiar with the IR stuff

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • YT2095
    0 YT2095 over 13 years ago in reply to dirtdiver

    for the IR side, you can consider the H/ware as a Gate, light comes on, resistance drops.

    that`s a single binary state, so you need some sort of protocol to get more than one state out of it, else you could just use 2 (or 3) pins to a 74138 and get your 4 (or 8) switch states from that.

    you could write your own protocol, a bit like Morse code for just your 3 switches, or use a Library that will also parse single line coms like I2C, Serial, IR, or even a Morse code look-up table! image

    the problem is more likely to be Which of these has a greater Memory economy?

    and so it becomes a Sizing excersise more than anything at this point, as All of the above will actually work, just how much Mem is left over for you to use?

     

    you could even go the RF route, with these TTL 433MHz transmitter/receivers (they`re only tiny!).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Reply
  • YT2095
    0 YT2095 over 13 years ago in reply to dirtdiver

    for the IR side, you can consider the H/ware as a Gate, light comes on, resistance drops.

    that`s a single binary state, so you need some sort of protocol to get more than one state out of it, else you could just use 2 (or 3) pins to a 74138 and get your 4 (or 8) switch states from that.

    you could write your own protocol, a bit like Morse code for just your 3 switches, or use a Library that will also parse single line coms like I2C, Serial, IR, or even a Morse code look-up table! image

    the problem is more likely to be Which of these has a greater Memory economy?

    and so it becomes a Sizing excersise more than anything at this point, as All of the above will actually work, just how much Mem is left over for you to use?

     

    you could even go the RF route, with these TTL 433MHz transmitter/receivers (they`re only tiny!).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
Children
  • dirtdiver
    0 dirtdiver over 13 years ago in reply to YT2095

    Memory is an issue couse i do have alot of writing to do , and i dont need that much resolution.

    What I mean is that I can set that LED to a value of 85, 170,255 and the LDR will be set to 3 sectors -the first one - >10 <130; second - >130, <200, 3rd sector- >200, And that will set one of three pins on the ATtiny HIGH.

    Im not familiar with how to set frequency and other stuff on that IR led YET...so i guess that will have to do

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube