Open danindiana opened 1 year ago
Solution: The operators % and & are not defined for floating point datatypes. Try integer datatypes instead.
//Write an extremely minimalist arduino neural network program that correctly compiles and runs on the Atmel 328p microchip. Randomize the weights and generate output of the network for the serial monitor as a series of alphanumeric characters. Define operators % and & as interger datatypes.
int weights[3][3] = { {1, 0, 9}, {3, 7, 4}, {2, 8, 5} };
int x[3] = {1, 1, 0}; int sum[3] = {0, 0, 0}; int y[3] = {0, 0, 0};
void setup() { Serial.begin(9600);
for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { sum[i] = sum[i] + (x[j] & weights[i][j]); } }
for (int i = 0; i < 3; i++) { y[i] = sum[i] % 2; }
for (int i = 0; i < 3; i++) { Serial.print((char) y[i]); } }
void loop() { //empty }
C:\Users\walter\Documents\Arduino\sketch_jan24a\sketch_jan24a.ino:11:10: warning: narrowing conversion of 'random(10)' from 'long int' to 'float' inside { } [-Wnarrowing] {random(10)},