Code Error--Exclamation point

I am using Jonah Model’s code to read the switch state of a push button switch in my Flash/Arduino LED tester interface.

I get an error on the following line of code:

if (switchState ! lastSwitchState) {

The error reads

In function ‘void loop()’:
error: expected `)’ before ‘!’ token

I am not sure what function the exclamation point has in this script. Does anyone have any suggestions for what I might swap for the exclamation point? When I change it to an equals sign, there is no code error, but the push button is not being recognized AT ALL by Flash or my Processing Serial Proxy.

Thanks—v

The entire Arduino code is as follows:

/* ------------------------------------------------

  • Flash + Arduino LED Tester
  • by Jonah Model jmodel@parsaons.edu
  • modified from ARDUINO CONVERSATION, by beltran berrocal, b@progetto25zero1.com
  • ------------------------------------------------ */
    int inputInt ; // The incoming serial data is received as an integer
    int switchState = 0; // What is the current switch state?
    int lastSwitchState = 0; // Was the switch previously on, or off?
    int switchPin = 13; // Which digital i/o pin is setup for the switch?
    int potPin = 0; // Which analog pin gets the input from the potentiometer
    int currentPotVal = 0; // What is the current value from the potentiometer
    int lastPotVal = 0; // What was the last value from the potentiometer
    int counter = 0; // Counter for pinging serial port outbound
    //
    //-------------------------------------------------------------------------
    // SETUP
    //-------------------------------------------------------------------------
    void setup() {
    Serial.begin(19200); //setup serial conversation at 19200 baud
    pinMode(switchPin, INPUT); // sets the switch pin as input
    for (int i=0; i<12; i++) {
    pinMode(i, OUTPUT); // set all non-input pins to output
    digitalWrite(i,LOW);
    }
    Serial.println(“ready”);
    Serial.println(switchState);
    }
    //
    //-------------------------------------------------------------------------
    // LOOP
    //-------------------------------------------------------------------------
    void loop () {
    //-------------------------------------------------------------------------
    // Ping now and then
    //-------------------------------------------------------------------------
    if (counter == 5000) {
    Serial.println(“ready”);
    counter = 0;
    }
    counter ++ ;
    //------------------------------------------------------------------------ LED LOGIC
    // Get the number of bytes (characters) available for reading over the serial port.
    // Serial.available() will be greater than 0 if any data has come in.
    // (The serial buffer can hold up to 64 bytes)
    if(Serial.available() > 0) {
    //must be a request to light up an LED
    //inputInt should be a number 2-9, but in binary it will come in as 50-57
    inputInt = Serial.read();
    //
    if(inputInt > 50 && inputInt <= 57) {
    //a valid LED signal has been received from Flash
    // convert the byte to an int - getting ready for digitalWrite()
    int outputPort = inputInt-48;
    // Send back the number received as confirmation
    // IMPORTANT NOTE: Use Serial.println(), NOT Serial.print()
    Serial.println(outputPort);
    if(outputPort >= 2 && outputPort <= 9) {
    // turns all the LEDs OFF
    for (int i=2; i<10; i++) {
    digitalWrite(i,LOW);
    }
    // then turns your selected LED ON
    digitalWrite(outputPort, HIGH);
    }
    // when we’re done, default the inputInt to nothing
    inputInt = 0;
    }
    //-------------------------------------------------------BINARY LEDS
    // ON
    if(inputInt == 65) {digitalWrite(2, HIGH);}
    if(inputInt == 66) {digitalWrite(3, HIGH);}
    if(inputInt == 67) {digitalWrite(4, HIGH);}
    if(inputInt == 68) {digitalWrite(5, HIGH);}
    if(inputInt == 69) {digitalWrite(6, HIGH);}
    if(inputInt == 70) {digitalWrite(7, HIGH);}
    if(inputInt == 71) {digitalWrite(8, HIGH);}
    if(inputInt == 72) {digitalWrite(9, HIGH);}
    // OFF
    if(inputInt == 97) {digitalWrite(2, LOW);}
    if(inputInt == 98) {digitalWrite(3, LOW);}
    if(inputInt == 99) {digitalWrite(4, LOW);}
    if(inputInt == 100) {digitalWrite(5, LOW);}
    if(inputInt == 101) {digitalWrite(6, LOW);}
    if(inputInt == 102) {digitalWrite(7, LOW);}
    if(inputInt == 103) {digitalWrite(8, LOW);}
    if(inputInt == 104) {digitalWrite(9, LOW);}
    }
    //------------------------------------------------------------------------ SWITCH LOGIC
    // get the current state of the switch from our board
    switchState = digitalRead(switchPin);
    // if the switch has changed states, then let Flash know about it
    if (switchState ! lastSwitchState) {
    if (switchState == 1){
    Serial.println(“switchOff”);
    }
    else if (switchState == 0){
    Serial.println(“switchOn”);
    }
    }
    //// now store the state for later comparison
    lastSwitchState = switchState;
    //slows down the visualization: each sentence will be emitted every .5 seconds
    // delay(50);
    //------------------------------------------------------------------------ ANALOG POT LOGIC
    currentPotVal = analogRead(potPin);
    if (currentPotVal < (lastPotVal + 5) && currentPotVal > (lastPotVal - 5) ) {
    Serial.print(“potValue”);
    Se

I think it should be != (not equals, that is).

I think you are right.

Along these lines:

My Flash LED Model---Processing Serial Code----Arduino TRIO is finally working!