Разработка автоматической системы беспроводного управления светового шоу на базе контроллера

Анализ эстетических и психофизиологических основ светомузыки. Пределы автоматизации светомузыкального синтеза. Создание системы автоматического беспроводного светового шоу на базе контроллера Arduino. Ее реализация на техническом и на программном уровне.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 17.05.2016
Размер файла 756,6 K

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

if (cmp != 0)

{

uint16_t destAddr = i/CHANNELS_PER_DEVICE; chibiTx(destAddr, &chVal[i], CHANNELS_PER_DEVICE);

}

}

memcpy(prevChVal, chVal, MAX_CHANNELS); digitalWrite(dbgPin, LOW);

}

}

Листинг программы Illuminado

#include <chibi.h> #include <SPI.h>

#define CHANNELS_PER_DEVICE 6 // this is for printf

static FILE uartout = {0};

const int channel[] = {15, 18, 4, 8, 2, 19}; const int potCs = 14;

const int auxLed = 7; /***************************************/

/*!

*/

/***********************************************************/

void setup()

{

uint8_t i;

// fill in the UART file descriptor with pointer to writer.

fdev_setup_stream (&uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE); // The uart is the standard output device STDOUT.

stdout = &uartout ;

// init the potentiometer chip select pinMode(potCs, OUTPUT); digitalWrite(potCs, HIGH);

// init the aux led pinMode(auxLed, OUTPUT); digitalWrite(auxLed, LOW);

chibiInit();

chibiCmdInit(57600); // init the pins

for (i=0; i<CHANNELS_PER_DEVICE; i++)

{

pinMode(channel[i], OUTPUT); digitalWrite(channel[i], LOW);

}

chibiCmdAdd("getsaddr", cmdGetShortAddr); // set the short address of the node chibiCmdAdd("setsaddr", cmdSetShortAddr); // get the short address of the node printf("Illuminado 2014-02-04\n");

}

/***********************************************************/

/*!

*/

/***********************************************************/

void loop()

{

chibiCmdPoll();

// Check if any data was received from the radio. If so, then handle it. if (chibiDataRcvd() == true)

{

int i, len, rssi, src_addr;

byte buf[50]; // this is where we store the received data // retrieve the data and the signal strength

if ((len = chibiGetData(buf)) == 0) return; printf("%02X ", buf[i]);

for (i=0; i<CHANNELS_PER_DEVICE; i++)

{

// these are EL wire. if dimming is used, two channels get faded by the same amount switch (buf[i])

{

case (255): dim(i/2, 255);

digitalWrite(channel[i], HIGH); break;

case (0): dim(i/2, 255);

digitalWrite(channel[i], LOW); break;

default:

dim(i/2, buf[i]);

digitalWrite(channel[i], HIGH); break;

}

}

printf("\n\r");

}

}

/**********************************************************/

// USER FUNCTIONS /****************************************/

void dim(uint8_t addr, uint8_t val)

{

cli();

digitalWrite(potCs, LOW); SPI.transfer(addr); SPI.transfer(val); digitalWrite(potCs,HIGH); sei();

}

/***********************************************************/

/*!

Get short address of device from EEPROM Usage: getsaddr

*/

/***********************************************************/

void cmdGetShortAddr(int arg_cnt, char **args)

{

int val;

val = chibiGetShortAddr();

Serial.print("Short Address: "); Serial.println(val, HEX);

}

/***********************************************************/

/*!

Write short address of device to EEPROM Usage: setsaddr <addr>

*/

/********************************************************/

void cmdSetShortAddr(int arg_cnt, char **args)

{

int val;

val = chibiCmdStr2Num(args[1], 16); chibiSetShortAddr(val);

}

/***********************************************************/

// This is to implement the printf function from within arduino

/***********************************************************/

static int uart_putchar (char c, FILE *stream)

{

Serial.write(c); return 0;

}

Размещено на Allbest.ru

...

Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.