GithubHelp home page GithubHelp logo

Help? about avr-programming HOT 2 CLOSED

hexagon5un avatar hexagon5un commented on July 17, 2024
Help?

from avr-programming.

Comments (2)

hexagon5un avatar hexagon5un commented on July 17, 2024

Heya!

There's good stuff here: you set up the pullups, initialized the overall pin-interrupt (PCIE2), and test for both pins in the ISR. But the confusion here is that both buttons are controlling the same LED.

So when you test BUTTON, it sets the LED, and then the code goes directly to testing BUTTON3. This all happens so fast that you don't even notice that it's working on BUTTON. Try setting/clearing another LED on the other button and you should see that it works.

By the way, I really like this basic approach to learning code -- you build up as simply as possible on the code in the book. This way, a) you make the code your own, and b) you can push it until it breaks and you'll learn something deeper about the way the demo works. Sweet.

from avr-programming.

hballinas avatar hballinas commented on July 17, 2024

Thank you Elliot. I am really enjoying your book and would be thrilled to be able to ask you more questions as I go along. I was able to make it work, 2 pins changing the state of the same LED by changing the condition as noted below. I don't know if this is public, but I include it for any other person going through your book as I am. The reason I wanted it this way is because I'm thinking about using an AVR to light up an AUTOART car model, and I need the doors to activate the interior light when the doors open. By the way, do you happen to know if the IRremote.h library can be used along with AVR Studio? If not, do you happen to know a library to use an IR remote with an AVR using C and not C++?

Code:
ISR(PCINT2_vect) { /Run every time there is a change on button... ISR is a macro that denotes a function of interrupt.h/
if (bit_is_set(BUTTON_PIN, BUTTON|BUTTON3)) //PIND, PD2//
{
LED_PORT &= ~(1 << LED1); //PORTB, PB1//
}
else {
LED_PORT |= (1 << LED1); //PORTB, PB1//
}

from avr-programming.

Related Issues (20)

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.