From: Erik Andresen Date: Sat, 21 Nov 2026 17:44:15 +0000 (+0100) Subject: Nano: Added laserpointer X-Git-Url: https://defiant.homedns.org/gitweb/?a=commitdiff_plain;h=4c13d547130f9964201fd0bed70bc64c6b1df14c;p=wt_open_manipulator.git Nano: Added laserpointer --- diff --git a/avr/nano/main.c b/avr/nano/main.c index af61e70..830ded9 100644 --- a/avr/nano/main.c +++ b/avr/nano/main.c @@ -30,7 +30,7 @@ * D4 PD4/T0 * D5 PD5/OC0B/T1 * D6 PD6/OC0A/AIN0 LED - * D7 PD7/AIN1 + * D7 PD7/AIN1 Pointlaser * D8 PB0/ICP1 * D9 PB1/OC1A * D10 PB2/SS/OC1B @@ -59,8 +59,7 @@ static uint8_t slave_cmd(uint8_t ins, const uint8_t* param, uint8_t param_len, if (ins == DYNAMIXEL_WRITE && param_len == 3 && addr == 1) { OCR0A = 255 - param[2]; return 1; // status reply, ERR = 0 - } - if (ins == DYNAMIXEL_READ && addr == 2) { + } else if (ins == DYNAMIXEL_READ && addr == 2) { uint16_t temp = mlx90614_read_temp_tenths(); if (temp == 0) { *err = 0x04; // hardware error: sensor read failed @@ -70,12 +69,18 @@ static uint8_t slave_cmd(uint8_t ins, const uint8_t* param, uint8_t param_len, *reply_len = 2; } return 1; + } else if (ins == DYNAMIXEL_WRITE && param_len == 3 && addr == 3) { + if (param[2]) { + PORTD |= (1<<7); + } else { + PORTD &= ~(1<<7); + } } return 0; // stay silent } int main(void) { - DDRD = (1<<6); + DDRD = (1<<6) | (1 << 7); PORTD = (1<<6); PORTC = (1<<4) | (1<<5); // I2C Pullups setup_uart(9600);