my code dont work but i get my computer dont see the problem

I really want help gettign this problem solved. Nothing works on my bredboard and when i press control button the serial motor just prints 8 and nothing more. heres the code:
#include <Button.h>

#include <Adafruit_TiCoServo.h>
#include <known_16bit_timers.h>

#include <Adafruit_NeoPixel.h>

Button startbutton (3);
Button guessbutton (4);
Button controllbutton (5);
Adafruit_NeoPixel ring = Adafruit_NeoPixel(24, 10, NEO_GRB);
Adafruit_TiCoServo coinservo;
Adafruit_TiCoServo jackpotservo;
byte playerguess;
const byte winnumber (random(1, 25));
const byte neoPin = 10;
const byte neoPixels = 24;
const byte neobright = 100;

void setup() {
ring.begin();
ring.show();
coinservo.attach(6);
jackpotservo.attach(7);
startbutton.begin();
guessbutton.begin();
controllbutton.begin();
}
void loop() {
if (guessbutton.pressed()) {
playerguess + 1;
}
if (startbutton.pressed() && playerguess > 0) {
delay(20000);
coinservo.write(180);
delay(200);
coinservo.write(0);
}
if (controllbutton.pressed()) {
rainbowCycle();
Wheel(0); //startvärde 0?

if (playerguess = winnumber) {
jackpotservo.write(180);
}
}
}
void rainbowCycle() {
uint16_t i, j;
for (j = 0; j < 256; j++) {
for (i = 0; i < neoPixels; i++) {
ring.setPixelColor(i, Wheel(((i * 256 / neoPixels) + j) & 255));
}
ring.show();
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return ring.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return ring.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return ring.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Casino_maskin.ino (1.57 KB)

Instead of this:

 playerguess + 1;

You probably want:

 playerguess++;

Also the following line of code is a problem:

    if (playerguess = winnumber)

It should be:

    if (playerguess == winnumber)

umu_scorpion:
I really want help gettign this problem solved. Nothing works on my bredboard and when i press control button the serial motor just prints 8 and nothing more

You says the serial monitor just prints 8 but you haven't configured the serial interface. You should configure your serial interface and print some debug statements.

It would also be helpful to provide a wiring diagram.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.