1kB challange - /1kc/

What whare you working on Sup Forums? Have you already started?

hackaday.io/contest/18215-the-1kb-challenge

Other urls found in this thread:

atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf
hackaday.com/2016/11/21/step-up-to-the-1-kb-challenge/
nongnu.org/avr-libc/user-manual/group__util__delay.html
atmel.com/images/doc1497.pdf
twitter.com/SFWRedditImages

>1kB

Seems pretty boring when you get so much resource to work with.

...What?

1KB? Isn't that a lot? Aren't there 64B demos and shit?

OP here,
I want to do something embedded. Any ideas?
Got stuff liek this:
>buttons
>switches
>7400 NAND-Gates
>MOSFETS (not in picture)
>LEDs
>L298N motor driver
>sound sensor (not in picture)
>attiny85 (will be replaced by attiny13, but doesnt matter I guess)
>433MHz modules

What do? Thought about maybe some sort of self driving car maybe with IR sensors, but not sure if this would fit into 1kB.
And I am not sure, but if I want to use those rf modules either chip only has to have 512bytes...

t. """""""""professional""""""""""""""""""""" meme.js developer

forgot picture

It is a lot, but question is: How much can you do with it?

OP here,
did simple blink sketch just to have an impression how much 1kB is.
#include
#include

#define F_CPU 1000000

int main() {

DDRB = 0xFF;
while(1) {
PORTB |= (1

pic related.
So 1kB is really not very much, m9.

That's nice

On the contrary, things get fun when you're limited in resources.
That forces you to be creative, and in the process you get good ideas.

t. A wannabe SNES programmer

a clap code activated coffee-maschine

should be all the parts to create a "add-on" to a regular one only except putting in water+coffee

Wew, this sounds nice.
My thought maybe a water kettle which boils my water only to 80°C for my green tea (or different temperatures on button press), since my old one doesn't have a temperature sensor - maybe I'll add one and add that clap idea.

But that would be more of an analog electronic than a programming exercise.

nice trips.

That doesn't actually matter imo. It just have to be somewhat creative. Guess I won't get under first four places anyways...

I compiled it for atmega328p.
$ avr-gcc avr.c -o test.elf -Os -mmcu=atmega328p -DF_CPU=1000000UL
$ avr-size -C --mcu=atmega328p test.elf AVR Memory Usage
----------------
Device: atmega328p

Program: 178 bytes (0.5% Full)
(.text + .data + .bootloader)

Data: 0 bytes (0.0% Full)
(.data + .bss + .noinit)


but let's make a change. we can toggle pin state by writing to pin register, like that
#include
#include

int main() {

DDRB = 0xFF;
while(1) {
PINB |= (1

wew, didn't knew that.
Apperently your solution doesn't work on attiny85, but this works and saves space, too:
#include
#include

#define F_CPU 1000000

int main() {

DDRB = 0xFF;
while(1) {
PORTB ^= (1

I highly believe your code will get 50-ish byte size written in ASM.

I have never ever written ASM though.

well you can as i said use the inputs and be creative with them as i said "clap code" also you can use leds as outputs

if you really want to use up the 1kb as a whole you would need a lot more data to handle since logic isnt that big

It should work.
atmel.com/images/atmel-2586-avr-8-bit-microcontroller-attiny25-attiny45-attiny85_datasheet.pdf
>10.2.2 Toggling the Pin
>Writing a logic one to PINxn toggles the value of PORTxn, independent on the value of DDRxn. Note that the SBI instruction can be used to toggle one single bit in a port.
And when you compile it with -Os,
PINB |= (1

What will I win? A bunch of facebook likes?

>What will I win? A bunch of facebook likes?
hackaday.com/2016/11/21/step-up-to-the-1-kb-challenge/
Grand prize is a Digi-Comp II kit from EMSL
First prize is a Maker Select 3D printer V2
Second Prize is a Bulbdial Clock kit from EMSL
Third Prize is a Blinkytile kit from Blinkinlabs

>Grand prize is worse than first prize

oh yes, it does work. Thanks m8!
I have not seen that you used "PINB" instead of "PORTB".

Try that, it's not hard.
Also I think
Loop:
...
goto Loop;

must take less space than while (1) { ... }

64kb, not 64b

And setting only one bit in DDRB instead of whole register also saves space.
#include
#include

int main()
{
DDRB |= (1

>but while(1) is compiled to something like that
Amazing.

>DDRB |= (1

3d printers are garbage unless you have a heavy duty industrial one

sbi 0x17,0
0x17 is the address of DDRB register. It sets bit0 in DDRB to 1. And bit0 is PB0. It takes two bytes.

literally 8000 bits of program memory

And if we check _delay_ms documentation, we can see that The maximal possible delay is 262.14 ms / F_CPU in MHz. We run our attiny at 1MHz, so chagning delay value from 500 to 262 produces smaller program. 70 bytes instead of 76.
nongnu.org/avr-libc/user-manual/group__util__delay.html

Can we make it even smaller? Perhaps by using timer interrupt instead of delay loop?

What is this soccery, am I really on Sup Forums?
Never thought that I would learn so much on Sup Forums, wtf.
>we are only discussing about a simple blink sketch here
wew

PS: for me it's 72 bytes then

#include
#include

int main()
{
DDRB |= (1

why does
>DDRB = 0x01;
need 2 bytes more than
>DDRB |= (1

See
Almost every command in 2 bytes wide, so in the DDRB = 0x01 statement you get at first 0x01 value loaded into some temporary register, and later this value is pushed from temporary register into DDRB.

Oh okay, thanks!
So fuckin sick how much you can learn with that stuff if you really focus on getting the best out of it. I am impressed

because it first hast to load 0x01 to a register and then save it in memory under address of DDRB register.
two bytes for loading 0x01 to a register
two bytes for saving it to memory

but there is a two byte instruction that allows you to set a specific bit in a register to one, so it's more efficient to use that when you need to change only one pin

You guys really inspire me to learn, thanks for being

Shitty developers like you are the reason why everything is so bloated these days

Any resources for learning low level C? Specifically microcontrollers.

tips from atmel atmel.com/images/doc1497.pdf

Thanks user.

Why do peeps on gee don't make more of this stuff? ;_;

All that anime shit makes me a sad pepe

That VGA blinking project looks nice.