Attiny85 | RubberDucky like payloads for DigiSpark Attiny85 | Hacking library
kandi X-RAY | Attiny85 Summary
kandi X-RAY | Attiny85 Summary
For people who can't buy or are too cheap to buy RubberDucky, DigiSpark Attiny85 is the solution to their problems. Because it's possible to use it as HID thanks to "DigiKeyboard.h" it can be use as keyboard to send keystrokes to computer which can be use for pranking your people to creating a backdoor in target system.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of Attiny85
Attiny85 Key Features
Attiny85 Examples and Code Snippets
Community Discussions
Trending Discussions on Attiny85
QUESTION
What is the best way to hardcode the compiler's -D flag into the source files?
I want to put the #define in one of the headers and then import bunch of stuff that should react to that define. Does it work like that? Which header should I put it? Or directly to main.c? Or to all of them?
TMI-details: The environment here is digispark hw-018 (attiny85 with built-in usb programmer) and the #define should replace -DUSE_SOFTWARE_SPI so I can use AVR-CAN library in SPI mode to read stuff from MCP2515.
EDIT: After some annoying banging head to the wall the top of main.c looks now like this and it still does not work.
...ANSWER
Answered 2020-Nov-25 at 17:43There are a couple of approaches here.
If it's just a single main.c
source file, then putting this at the top of the file is fine:
QUESTION
for a battery powered project I would like to put an Attiny85 into deep sleep mode immediately after program start and let it wake up only when a sensor value (in this case a photo resistor) changes. Unfortunately I could only find examples for interrupts by a button and not for photo resistors in the internet. Does anyone have an idea how I could implement it, or if it is impossible?
...ANSWER
Answered 2020-Jul-25 at 19:41Turn out that this is probably a software question.
Probably to lowest power and simplest way to implement this would be to...
- Connect the analog sensor value to any one of the analog input pins on the ATTINY.
- Make sure you disable the digital buffer on that pin.
- Set up the ADC to point to the pin and set other relevant values like precaller.
- Set up a watchdog timer to fire a periodic interrupt.
- Go into deep sleep and wait for the watchdog timer to fire.
Each time the watchdog fires...
- Enable the the ADC.
- Take a sample.
- Jump to main code if the value has changed more than your threshold.
- Disable ADC.
- Go back to deep sleep.
How power efficient this will be really depends on how often the timer interrupt fires - the less often the better. If your application can live with only checking the sensor, say, once per second then I bet power usage will be single digits of microamps or less.
If you really need very low latency when that sensor values changes, then you could instead use the build in analog comparitor... .. to generate an interrupt when the input voltage goes above or below a threshold value, but this will likely use much more power since just the analog comparitor itself uses ~30ua while on, and you will also need to generate the voltage that you are comparing to either with the internal 1.1 voltage reference or an external resistor bridge or buffer capacitor.
QUESTION
i was able to make the following code after about a week of desk head banging, it works, kind of. the problem is that it's not that responsive, most of the times i have to spam the buttons on my phone to send the same command over and over again until it catches up.
Can you help me clean the code a bit?
As you will see, at times it seems i over complicated things but that is only cause i found it works better this way then what it seems to be a more "logical" simpler version. i will lay the code and then i will explain and ask my questions.
...ANSWER
Answered 2020-Jul-21 at 01:43I'm bored and feeling generous so here you go. See if you can follow this. It's uncompiled and untested so I can't guarantee it does exactly what you want, but see if you can understand what I'm trying to do here. Nothing ever stops and waits for anything to happen. There are no delay calls. There is no waiting. Just cycling through and see if it is time to do something.
One change I made that doesn't affect this, just makes typing easier was to take all your goLED variables and make an array out of them. Anytime you catch yourself putting numbers on variable names, use an array instead so the compiler has access to those numbers and you don't have to repeat yourself. See how much simpler the checkLedData function got.
Then I made the colorWipe functions so that they will return a boolean, true if they've completed and false if they haven't. Then the runLED function can just check that to see if it is time to move on to the next step. For the first case it is easy, just set the goLED variable to whatever the colorWipe returns. As long as it is still working it returns true and goLED[1] stays true and you keep calling the same colorWipe function. For the others we have to make them state machines, so I added a state variable. When any of them get finished they set their goLED variable back to false. When all of those are false, meaning there's no effect currently running, then runLED will fall all the way through to the last else statement and go to see if there is another command.
Like I said, there may be a mistake or two in there. But see if you can understand how I am writing a checklist to see what needs to happen instead of a story to tell one thing right after another.
QUESTION
I want to program a ATtiny85 microcontroller and have realized that my program needs a bit of delay to work properly. I am using MPLabX and the XC8 compiler. So I should be able to use the __delay_ms() macro and MPLab does recognize the macro and does NOT put the red line under the code. However when I try to compile the programm, there is an error thrown at each line where I use the macro. "Undefined reference to __delay_ms" And also an additional "implicit declaration of __delay_ms" for the first line that uses the macro. I do have _XTAL_FREQ defined correctly and xc.h included.
The code also compiles just fine without the delay macros, but than it doesn't work correctly, so I need the delay.
I don't know what the problem is. I have programmed other microcontrollers with the __delay_ms macro before. I am also using the latest version of the XC8 compiler. And according to the documentation of the compiler the version is fully compatible with the ATtiny85.
I also tried to find a solution on the internet, but didn't find anything that helped with my problem...
Any ideas where the problem could be?
...ANSWER
Answered 2020-Jul-08 at 10:50Maybe this should be a comment, but I want to give you an example which compiles fine for me:
This is the way it works for a PIC
compiler: xc8 2.0
QUESTION
everyone, i've been trying to use Arduino IDE 1.8.12 to compile scripts into a Digispark ATTiny85 usb board from a 4GB Raspberry Pi 4 running Raspberry Pi OS.
First problem i was that when going to the IDEs board manager to install the Digistump, it gave back the "micronucleus is not available for your operating system" error. I managed to work around this by replacing the json url suggested by digistump by the one provided on the second entry of this post. After doing so, a "compatible" version of Digistump was listed on the boards manager and was able to successfully select the Digispark board and the micronucleus programmer under the Arduino IDEs Tools dropdown menu.
This is where the second problem appeared: As i compile the script, the Arduino IDE console returns the following message:
" Arduino: 1.8.12 (Linux), Board: "Digispark (Default - 16.5mhz)" Sketch uses 2788 bytes (46%) of program storage space. Maximum is 6012 bytes. Global variables use 124 bytes of dynamic memory. An error occurred while uploading the sketch /home/pi/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher: 1: /home/pi/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher: Syntax error: word unexpected (expecting ")") " And that's as far as i could go without getting messy or going into stuff i didn't quite understand.
Now, a few considerations:
-As I said, im running raspberry pi os on a 4GB raspberry pi 4 and using Arduino IDE 1.8.12
-Also, im kind of a newbie, even though i've been coding on an arduino UNO for about a year, i've never tried any other boards, also, I got the pi on march this year and it IS my first encounter with linux based systems, I've noticed things can get really messy or complex very fast so please have patience with me :)
-This is my first stackoverflow question and even though i've read the guidelines to posting questions here, something might have escaped my attention, also, i did search for this before asking but again, maybe i didn't see the right post, if my question is either poorly detailed, already answeed elsewhere, or anyhing can be improved about it, please let me know.
thank you all in advance for the amazing community you carry upon your shoulders.
cheers from argetina Yeti.
...ANSWER
Answered 2020-Jul-06 at 14:20To anyone out there who might run into this problem, I was able to fix this by following a comment on the post linked on the question, by doing:
sudo apt install git
git clone https://github.com/micronucleus/micronucleus
cd micronucleus/commandline/
sudo apt install libusb-dev
make
cp micronucleus ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4
sudo cp 49-micronucleus.rules /etc/udev/rules.d/.
git clone https://github.com/digistump/avr-dummy cd avr-dummy make cp avrdude ~/.arduino15/packages/digistump/tools/micronucleus/2.0a4/launcher
Note: I had already done this before, but I think it didn't work because i had gotten messy with the alternatives, this option worked for me only after doing a fresh installation Arduino IDE.
Like on that arduino.cc post, I am now able to upload my payloads to the digispark with no problem what so ever.
Cheers
QUESTION
I'm relatively new to programming microcontrollers, so I started experimenting on an ATtiny85.
First program was simply turning on an LED and off with a little delay (classic blinky program).
Now I wanted to slowly increase the brightness of the LED. Here is the code:
...ANSWER
Answered 2020-May-01 at 18:12__delay_ms()
is converted to cycle-wasting instructions by the compiler, so as long as your F_CPU
matches the current speed of the processor, then it should work as expected.
I would look for other places in your code that are not working as you expect them to.
A half second delay at power up is not a great diagnostic test since it happens quickly, only once, and there may be other things going on then as well.
Maybe instead try blinking between two different brightness levels with a 500ms delay between. Visually this should be unambiguous.
if that works as expected, then maybe try doing a brightness ramp and changing the delay inside the loop to see if that works as expected.
Eventually you will work your way up to something that is not as expected, and then you will know where the problem is. It is still possible you will not understand what is going on, but at least you will be able to ask a much more specific question here and be more likely to get a helpful answer.
Report back with your results!
QUESTION
So recently I tried to implement Software UART (TX only) for the ATTiny85. I want to drive it with the internal Timer1.
The timer shall interrupt with the frequency of the Baudrate. Every ISR one bit will be transmitted, until there is nothing left to send and the interrupt will be disabled again.
(Note: F_CPU=1000000 ; Fuses are the factory default (E:FF, H:DF, L:62) )
...ANSWER
Answered 2020-Apr-02 at 19:16I think I found a problem that could cause what you are seeing.
In CTC mode, this timer clears the counter after it reaches OCR1C
...
You do not seem to be setting OCR1C
in your code so the period of the timer will be based on whatever happens to be in OCR1C
(which is 0
at power up).
This is an easy thing to miss (OCR1C
vs OCR1A
)!
I think you can make your code work by adding a line to set this register here...
QUESTION
A very novice question I'm afraid, but I've tried my best to understand this and have got nowhere as I have little experience with C programming.
I'm currently picking up an old project from a year or two ago from Instructables: https://www.instructables.com/id/Jar-of-Fireflies/
This includes a C file for firmware written for a Firefly pattern, however this was written a good 12 years ago.
However... I am not following the instructable to the Nth degree. Instead I am using a DIP AtTiny85, which I have previously programmed using an Arduino as ISP. And hence want to be able to compile the code in Arduino IDE or Atmel Studio, with Visual Micro plugin.
Every time this is compiled in Arduino IDE, I receive the following error: 'prog_uint8_t' does not name a type, and this causes lots of errors to roll through.
From what I understand, this deceleration was removed/changed as part of the AVR GCC in around 2010ish... Is there anyway I can get this to compile correctly to run the code? Maybe using a macro or including a library. I have tried a few libraries such as #include
, but believe this should be taken care of as part of automated include. I'm sure if I brought the proper programmer my problem may go away but I'm sure there is an easy fix for this..?
Code provided as .tgz in instructable link above which includes headers, c executables, hex etc.,
for quick reading of the main c executable declarations....
...ANSWER
Answered 2019-Jul-14 at 01:48It was depreciated however you should be able to get it to work by adding the following code before your usage of prog_uint8_t
QUESTION
I am new to programming microcontrollers and I've just started using Attiny85. I am trying to build a circuit for LED with tactile switch. Every time the tactile switch is pressed it jumps the LED to next state of operation. Since it is battery operated, when the LED is OFF I want the attiny 85 to consume as low current as possible. As of now it is consuming 4mA when the LED is OFF without sleep mode. So I tried the power down mode for Attiny 85 but some how i am stuck in the power down mode
...ANSWER
Answered 2020-Jan-29 at 14:35Please refer to the datasheet, section 7.1 Sleep Modes at page 34.
In the table you can see, in Power-down mode only 3 sources can wake up the CPU:
- INT0, only level interrupt and pin change interrupt
- USI module start condition
- Watchdog interrupt
That means, if you want the part to wake up when button has been pressed, then best option will be to configure the pin change interrupt.
First you need to configure an interrupt service routine (ISR). The ISR is required just to handle the interrupt event, without it the program will be restarted. Since there is no action required, the ISR can be empty:
QUESTION
I have been on this issue for more than 3 days now after I got my SSD1306 I2C in the mail. I have a Tiny Programmer from Sparkfun, which I use with a breadboard.
This is my pin layout: pin2-->SDA, pin3-->SCL. The documentation on the SSD1306 Arduino library states that I have to use these pins even though I know the SDA is pin5 and SCL is pin7. The power and ground are being jumped to the OLED from the Tiny Programmer.
The main issue I am having is that the OLED is not coming on or displaying the text.
The code I am using for this is:
...ANSWER
Answered 2018-Jan-31 at 16:12I think you have to use pins 5
and 7
with the attiny85
. You also need to use tinywirem.h
for I2C communication.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Attiny85
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page